mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:24:45 +01:00
efi_secret: clean securityfs use up
securityfs_remove() does take care of entire subtree now; no need to mess with them individually. NB: ->i_op replacement in there is still buggy. One shouldn't ever modify ->i_op of live accessible inode. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
29d673b150
commit
a98ce0275b
1 changed files with 8 additions and 29 deletions
|
|
@ -31,8 +31,6 @@
|
|||
|
||||
struct efi_secret {
|
||||
struct dentry *secrets_dir;
|
||||
struct dentry *fs_dir;
|
||||
struct dentry *fs_files[EFI_SECRET_NUM_FILES];
|
||||
void __iomem *secret_data;
|
||||
u64 secret_data_len;
|
||||
};
|
||||
|
|
@ -119,10 +117,8 @@ static void wipe_memory(void *addr, size_t size)
|
|||
|
||||
static int efi_secret_unlink(struct inode *dir, struct dentry *dentry)
|
||||
{
|
||||
struct efi_secret *s = efi_secret_get();
|
||||
struct inode *inode = d_inode(dentry);
|
||||
struct secret_entry *e = (struct secret_entry *)inode->i_private;
|
||||
int i;
|
||||
|
||||
if (e) {
|
||||
/* Zero out the secret data */
|
||||
|
|
@ -132,10 +128,6 @@ static int efi_secret_unlink(struct inode *dir, struct dentry *dentry)
|
|||
|
||||
inode->i_private = NULL;
|
||||
|
||||
for (i = 0; i < EFI_SECRET_NUM_FILES; i++)
|
||||
if (s->fs_files[i] == dentry)
|
||||
s->fs_files[i] = NULL;
|
||||
|
||||
return simple_unlink(inode, dentry);
|
||||
}
|
||||
|
||||
|
|
@ -186,15 +178,6 @@ unmap:
|
|||
static void efi_secret_securityfs_teardown(struct platform_device *dev)
|
||||
{
|
||||
struct efi_secret *s = efi_secret_get();
|
||||
int i;
|
||||
|
||||
for (i = (EFI_SECRET_NUM_FILES - 1); i >= 0; i--) {
|
||||
securityfs_remove(s->fs_files[i]);
|
||||
s->fs_files[i] = NULL;
|
||||
}
|
||||
|
||||
securityfs_remove(s->fs_dir);
|
||||
s->fs_dir = NULL;
|
||||
|
||||
securityfs_remove(s->secrets_dir);
|
||||
s->secrets_dir = NULL;
|
||||
|
|
@ -209,7 +192,7 @@ static int efi_secret_securityfs_setup(struct platform_device *dev)
|
|||
unsigned char *ptr;
|
||||
struct secret_header *h;
|
||||
struct secret_entry *e;
|
||||
struct dentry *dent;
|
||||
struct dentry *dent, *dir;
|
||||
char guid_str[EFI_VARIABLE_GUID_LEN + 1];
|
||||
|
||||
ptr = (void __force *)s->secret_data;
|
||||
|
|
@ -232,8 +215,6 @@ static int efi_secret_securityfs_setup(struct platform_device *dev)
|
|||
}
|
||||
|
||||
s->secrets_dir = NULL;
|
||||
s->fs_dir = NULL;
|
||||
memset(s->fs_files, 0, sizeof(s->fs_files));
|
||||
|
||||
dent = securityfs_create_dir("secrets", NULL);
|
||||
if (IS_ERR(dent)) {
|
||||
|
|
@ -243,14 +224,13 @@ static int efi_secret_securityfs_setup(struct platform_device *dev)
|
|||
}
|
||||
s->secrets_dir = dent;
|
||||
|
||||
dent = securityfs_create_dir("coco", s->secrets_dir);
|
||||
if (IS_ERR(dent)) {
|
||||
dir = securityfs_create_dir("coco", s->secrets_dir);
|
||||
if (IS_ERR(dir)) {
|
||||
dev_err(&dev->dev, "Error creating coco securityfs directory entry err=%ld\n",
|
||||
PTR_ERR(dent));
|
||||
return PTR_ERR(dent);
|
||||
PTR_ERR(dir));
|
||||
return PTR_ERR(dir);
|
||||
}
|
||||
d_inode(dent)->i_op = &efi_secret_dir_inode_operations;
|
||||
s->fs_dir = dent;
|
||||
d_inode(dir)->i_op = &efi_secret_dir_inode_operations;
|
||||
|
||||
bytes_left = h->len - sizeof(*h);
|
||||
ptr += sizeof(*h);
|
||||
|
|
@ -266,15 +246,14 @@ static int efi_secret_securityfs_setup(struct platform_device *dev)
|
|||
if (efi_guidcmp(e->guid, NULL_GUID)) {
|
||||
efi_guid_to_str(&e->guid, guid_str);
|
||||
|
||||
dent = securityfs_create_file(guid_str, 0440, s->fs_dir, (void *)e,
|
||||
dent = securityfs_create_file(guid_str, 0440, dir, (void *)e,
|
||||
&efi_secret_bin_file_fops);
|
||||
if (IS_ERR(dent)) {
|
||||
dev_err(&dev->dev, "Error creating efi_secret securityfs entry\n");
|
||||
ret = PTR_ERR(dent);
|
||||
goto err_cleanup;
|
||||
}
|
||||
|
||||
s->fs_files[i++] = dent;
|
||||
i++;
|
||||
}
|
||||
ptr += e->len;
|
||||
bytes_left -= e->len;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue