pstore: Replace arguments for erase() API
This removes the argument list for the erase() callback and replaces it with a pointer to the backend record details to be removed. Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
Родитель
83f70f0769
Коммит
a61072aae6
|
@ -927,8 +927,7 @@ static int erst_open_pstore(struct pstore_info *psi);
|
||||||
static int erst_close_pstore(struct pstore_info *psi);
|
static int erst_close_pstore(struct pstore_info *psi);
|
||||||
static ssize_t erst_reader(struct pstore_record *record);
|
static ssize_t erst_reader(struct pstore_record *record);
|
||||||
static int erst_writer(struct pstore_record *record);
|
static int erst_writer(struct pstore_record *record);
|
||||||
static int erst_clearer(enum pstore_type_id type, u64 id, int count,
|
static int erst_clearer(struct pstore_record *record);
|
||||||
struct timespec time, struct pstore_info *psi);
|
|
||||||
|
|
||||||
static struct pstore_info erst_info = {
|
static struct pstore_info erst_info = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
@ -1100,10 +1099,9 @@ static int erst_writer(struct pstore_record *record)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int erst_clearer(enum pstore_type_id type, u64 id, int count,
|
static int erst_clearer(struct pstore_record *record)
|
||||||
struct timespec time, struct pstore_info *psi)
|
|
||||||
{
|
{
|
||||||
return erst_clear(id);
|
return erst_clear(record->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init erst_init(void)
|
static int __init erst_init(void)
|
||||||
|
|
|
@ -266,10 +266,7 @@ static int efi_pstore_write(struct pstore_record *record)
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pstore_erase_data {
|
struct pstore_erase_data {
|
||||||
u64 id;
|
struct pstore_record *record;
|
||||||
enum pstore_type_id type;
|
|
||||||
int count;
|
|
||||||
struct timespec time;
|
|
||||||
efi_char16_t *name;
|
efi_char16_t *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -295,8 +292,9 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data)
|
||||||
* Check if an old format, which doesn't support
|
* Check if an old format, which doesn't support
|
||||||
* holding multiple logs, remains.
|
* holding multiple logs, remains.
|
||||||
*/
|
*/
|
||||||
sprintf(name_old, "dump-type%u-%u-%lu", ed->type,
|
snprintf(name_old, sizeof(name_old), "dump-type%u-%u-%lu",
|
||||||
(unsigned int)ed->id, ed->time.tv_sec);
|
ed->record->type, (unsigned int)ed->record->id,
|
||||||
|
ed->record->time.tv_sec);
|
||||||
|
|
||||||
for (i = 0; i < DUMP_NAME_LEN; i++)
|
for (i = 0; i < DUMP_NAME_LEN; i++)
|
||||||
efi_name_old[i] = name_old[i];
|
efi_name_old[i] = name_old[i];
|
||||||
|
@ -321,8 +319,7 @@ static int efi_pstore_erase_func(struct efivar_entry *entry, void *data)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
|
static int efi_pstore_erase(struct pstore_record *record)
|
||||||
struct timespec time, struct pstore_info *psi)
|
|
||||||
{
|
{
|
||||||
struct pstore_erase_data edata;
|
struct pstore_erase_data edata;
|
||||||
struct efivar_entry *entry = NULL;
|
struct efivar_entry *entry = NULL;
|
||||||
|
@ -331,17 +328,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
|
||||||
int found, i;
|
int found, i;
|
||||||
unsigned int part;
|
unsigned int part;
|
||||||
|
|
||||||
do_div(id, 1000);
|
do_div(record->id, 1000);
|
||||||
part = do_div(id, 100);
|
part = do_div(record->id, 100);
|
||||||
sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec);
|
snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu",
|
||||||
|
record->type, record->part, record->count,
|
||||||
|
record->time.tv_sec);
|
||||||
|
|
||||||
for (i = 0; i < DUMP_NAME_LEN; i++)
|
for (i = 0; i < DUMP_NAME_LEN; i++)
|
||||||
efi_name[i] = name[i];
|
efi_name[i] = name[i];
|
||||||
|
|
||||||
edata.id = part;
|
edata.record = record;
|
||||||
edata.type = type;
|
|
||||||
edata.count = count;
|
|
||||||
edata.time = time;
|
|
||||||
edata.name = efi_name;
|
edata.name = efi_name;
|
||||||
|
|
||||||
if (efivar_entry_iter_begin())
|
if (efivar_entry_iter_begin())
|
||||||
|
|
|
@ -210,14 +210,12 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (record->psi->erase) {
|
if (!record->psi->erase)
|
||||||
mutex_lock(&record->psi->read_mutex);
|
|
||||||
record->psi->erase(record->type, record->id, record->count,
|
|
||||||
d_inode(dentry)->i_ctime, record->psi);
|
|
||||||
mutex_unlock(&record->psi->read_mutex);
|
|
||||||
} else {
|
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
|
||||||
|
mutex_lock(&record->psi->read_mutex);
|
||||||
|
record->psi->erase(record);
|
||||||
|
mutex_unlock(&record->psi->read_mutex);
|
||||||
|
|
||||||
return simple_unlink(dir, dentry);
|
return simple_unlink(dir, dentry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,25 +469,24 @@ static int notrace ramoops_pstore_write_buf_user(enum pstore_type_id type,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ramoops_pstore_erase(enum pstore_type_id type, u64 id, int count,
|
static int ramoops_pstore_erase(struct pstore_record *record)
|
||||||
struct timespec time, struct pstore_info *psi)
|
|
||||||
{
|
{
|
||||||
struct ramoops_context *cxt = psi->data;
|
struct ramoops_context *cxt = record->psi->data;
|
||||||
struct persistent_ram_zone *prz;
|
struct persistent_ram_zone *prz;
|
||||||
|
|
||||||
switch (type) {
|
switch (record->type) {
|
||||||
case PSTORE_TYPE_DMESG:
|
case PSTORE_TYPE_DMESG:
|
||||||
if (id >= cxt->max_dump_cnt)
|
if (record->id >= cxt->max_dump_cnt)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
prz = cxt->dprzs[id];
|
prz = cxt->dprzs[record->id];
|
||||||
break;
|
break;
|
||||||
case PSTORE_TYPE_CONSOLE:
|
case PSTORE_TYPE_CONSOLE:
|
||||||
prz = cxt->cprz;
|
prz = cxt->cprz;
|
||||||
break;
|
break;
|
||||||
case PSTORE_TYPE_FTRACE:
|
case PSTORE_TYPE_FTRACE:
|
||||||
if (id >= cxt->max_ftrace_cnt)
|
if (record->id >= cxt->max_ftrace_cnt)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
prz = cxt->fprzs[id];
|
prz = cxt->fprzs[record->id];
|
||||||
break;
|
break;
|
||||||
case PSTORE_TYPE_PMSG:
|
case PSTORE_TYPE_PMSG:
|
||||||
prz = cxt->mprz;
|
prz = cxt->mprz;
|
||||||
|
|
|
@ -177,15 +177,11 @@ struct pstore_record {
|
||||||
*
|
*
|
||||||
* @erase:
|
* @erase:
|
||||||
* Delete a record from backend storage. Different backends
|
* Delete a record from backend storage. Different backends
|
||||||
* identify records differently, so all possible methods of
|
* identify records differently, so entire original record is
|
||||||
* identification are included to help the backend locate the
|
* passed back to assist in identification of what the backend
|
||||||
* record to remove.
|
* should remove from storage.
|
||||||
*
|
*
|
||||||
* @type: in: pstore record type to write
|
* @record: pointer to record metadata.
|
||||||
* @id: in: per-type unique identifier for the record
|
|
||||||
* @count: in: Oops count
|
|
||||||
* @time: in: timestamp for the record
|
|
||||||
* @psi: in: pointer to the struct pstore_info for the backend
|
|
||||||
*
|
*
|
||||||
* Returns 0 on success, and non-zero on error.
|
* Returns 0 on success, and non-zero on error.
|
||||||
*
|
*
|
||||||
|
@ -215,9 +211,7 @@ struct pstore_info {
|
||||||
enum kmsg_dump_reason reason, u64 *id,
|
enum kmsg_dump_reason reason, u64 *id,
|
||||||
unsigned int part, const char __user *buf,
|
unsigned int part, const char __user *buf,
|
||||||
bool compressed, size_t size, struct pstore_info *psi);
|
bool compressed, size_t size, struct pstore_info *psi);
|
||||||
int (*erase)(enum pstore_type_id type, u64 id,
|
int (*erase)(struct pstore_record *record);
|
||||||
int count, struct timespec time,
|
|
||||||
struct pstore_info *psi);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Supported frontends */
|
/* Supported frontends */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче