"securityfs_remove" can fail if it tries to remove a non-empty directory. This can happen, for example, if it tries to remove a file and its parent directory while the file is busy: the file removal will be delayed and the directory removal will fail. This patch adds a return value to "securityfs_remove" so that the caller knows if it succeeded or not.
Signed-off-by: Salvatore Mesoraca <s.mesorac...@gmail.com> --- include/linux/security.h | 4 ++-- security/inode.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/linux/security.h b/include/linux/security.h index 79d85dd..ff022fc 100644 --- a/include/linux/security.h +++ b/include/linux/security.h @@ -1590,7 +1590,7 @@ extern struct dentry *securityfs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent); -extern void securityfs_remove(struct dentry *dentry); +extern int securityfs_remove(struct dentry *dentry); #else /* CONFIG_SECURITYFS */ @@ -1609,7 +1609,7 @@ static inline struct dentry *securityfs_create_file(const char *name, return ERR_PTR(-ENODEV); } -static inline void securityfs_remove(struct dentry *dentry) +static inline int securityfs_remove(struct dentry *dentry) {} #endif diff --git a/security/inode.c b/security/inode.c index 16622ae..41f42ea 100644 --- a/security/inode.c +++ b/security/inode.c @@ -183,28 +183,32 @@ EXPORT_SYMBOL_GPL(securityfs_create_dir); * This function is required to be called in order for the file to be * removed. No automatic cleanup of files will happen when a module is * removed; you are responsible here. + * + * Returns 0 if the remove succeeds, -errno on error. */ -void securityfs_remove(struct dentry *dentry) +int securityfs_remove(struct dentry *dentry) { + int ret = -EINVAL; struct dentry *parent; if (!dentry || IS_ERR(dentry)) - return; + return ret; parent = dentry->d_parent; if (!parent || d_really_is_negative(parent)) - return; + return ret; mutex_lock(&d_inode(parent)->i_mutex); if (simple_positive(dentry)) { if (d_is_dir(dentry)) - simple_rmdir(d_inode(parent), dentry); + ret = simple_rmdir(d_inode(parent), dentry); else - simple_unlink(d_inode(parent), dentry); + ret = simple_unlink(d_inode(parent), dentry); dput(dentry); } mutex_unlock(&d_inode(parent)->i_mutex); simple_release_fs(&mount, &mount_count); + return ret; } EXPORT_SYMBOL_GPL(securityfs_remove); -- 2.3.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/