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.

make securityfs_remove() remove the entire subtree

... and fix the mount leak when anything's mounted there.
securityfs_recursive_remove becomes an alias for securityfs_remove -
we'll probably need to remove it in a cycle or two.

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

Al Viro 29d673b1 2c58d42d

+12 -38
+2 -1
include/linux/security.h
··· 2211 2211 const char *target, 2212 2212 const struct inode_operations *iops); 2213 2213 extern void securityfs_remove(struct dentry *dentry); 2214 - extern void securityfs_recursive_remove(struct dentry *dentry); 2215 2214 2216 2215 #else /* CONFIG_SECURITYFS */ 2217 2216 ··· 2241 2242 {} 2242 2243 2243 2244 #endif 2245 + 2246 + #define securityfs_recursive_remove securityfs_remove 2244 2247 2245 2248 #ifdef CONFIG_BPF_SYSCALL 2246 2249 union bpf_attr;
+10 -37
security/inode.c
··· 281 281 } 282 282 EXPORT_SYMBOL_GPL(securityfs_create_symlink); 283 283 284 + static void remove_one(struct dentry *victim) 285 + { 286 + if (victim->d_parent == victim->d_sb->s_root) 287 + simple_release_fs(&mount, &mount_count); 288 + } 289 + 284 290 /** 285 291 * securityfs_remove - removes a file or directory from the securityfs filesystem 286 292 * ··· 299 293 * This function is required to be called in order for the file to be 300 294 * removed. No automatic cleanup of files will happen when a module is 301 295 * removed; you are responsible here. 296 + * 297 + * AV: when applied to directory it will take all children out; no need to call 298 + * it for descendents if ancestor is getting killed. 302 299 */ 303 300 void securityfs_remove(struct dentry *dentry) 304 - { 305 - struct inode *dir; 306 - 307 - if (IS_ERR_OR_NULL(dentry)) 308 - return; 309 - 310 - dir = d_inode(dentry->d_parent); 311 - inode_lock(dir); 312 - if (simple_positive(dentry)) { 313 - if (d_is_dir(dentry)) 314 - simple_rmdir(dir, dentry); 315 - else 316 - simple_unlink(dir, dentry); 317 - } 318 - inode_unlock(dir); 319 - if (dir == dir->i_sb->s_root->d_inode) 320 - simple_release_fs(&mount, &mount_count); 321 - } 322 - EXPORT_SYMBOL_GPL(securityfs_remove); 323 - 324 - static void remove_one(struct dentry *victim) 325 - { 326 - if (victim->d_parent == victim->d_sb->s_root) 327 - simple_release_fs(&mount, &mount_count); 328 - } 329 - 330 - /** 331 - * securityfs_recursive_remove - recursively removes a file or directory 332 - * 333 - * @dentry: a pointer to a the dentry of the file or directory to be removed. 334 - * 335 - * This function recursively removes a file or directory in securityfs that was 336 - * previously created with a call to another securityfs function (like 337 - * securityfs_create_file() or variants thereof.) 338 - */ 339 - void securityfs_recursive_remove(struct dentry *dentry) 340 301 { 341 302 if (IS_ERR_OR_NULL(dentry)) 342 303 return; ··· 312 339 simple_recursive_removal(dentry, remove_one); 313 340 simple_release_fs(&mount, &mount_count); 314 341 } 315 - EXPORT_SYMBOL_GPL(securityfs_recursive_remove); 342 + EXPORT_SYMBOL_GPL(securityfs_remove); 316 343 317 344 #ifdef CONFIG_SECURITY 318 345 static struct dentry *lsm_dentry;