Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

securityfs: pin filesystem only for objects directly in root

Nothing on securityfs ever changes parents, so we don't need
to pin the internal mount if it's already pinned for parent.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

+13 -8
+13 -8
security/inode.c
··· 112 112 struct dentry *dentry; 113 113 struct inode *dir, *inode; 114 114 int error; 115 + bool pinned = false; 115 116 116 117 if (!(mode & S_IFMT)) 117 118 mode = (mode & S_IALLUGO) | S_IFREG; 118 119 119 120 pr_debug("securityfs: creating file '%s'\n",name); 120 121 121 - error = simple_pin_fs(&fs_type, &mount, &mount_count); 122 - if (error) 123 - return ERR_PTR(error); 124 - 125 - if (!parent) 122 + if (!parent) { 123 + error = simple_pin_fs(&fs_type, &mount, &mount_count); 124 + if (error) 125 + return ERR_PTR(error); 126 + pinned = true; 126 127 parent = mount->mnt_root; 128 + } 127 129 128 130 dir = d_inode(parent); 129 131 ··· 169 167 dentry = ERR_PTR(error); 170 168 out: 171 169 inode_unlock(dir); 172 - simple_release_fs(&mount, &mount_count); 170 + if (pinned) 171 + simple_release_fs(&mount, &mount_count); 173 172 return dentry; 174 173 } 175 174 ··· 310 307 simple_unlink(dir, dentry); 311 308 } 312 309 inode_unlock(dir); 313 - simple_release_fs(&mount, &mount_count); 310 + if (dir == dir->i_sb->s_root->d_inode) 311 + simple_release_fs(&mount, &mount_count); 314 312 } 315 313 EXPORT_SYMBOL_GPL(securityfs_remove); 316 314 317 315 static void remove_one(struct dentry *victim) 318 316 { 319 - simple_release_fs(&mount, &mount_count); 317 + if (victim->d_parent == victim->d_sb->s_root) 318 + simple_release_fs(&mount, &mount_count); 320 319 } 321 320 322 321 /**