[PATCH 1/1] security: avoid a leak in securityfs_remove()

Yuanjun Gong ruc_gongyuanjun at 163.com
Thu Jun 2 07:29:43 UTC 2022


Delete the dentry in securityfs_remove() to make sure the
dentry is not used by another thread and live longer than
the call of securityfs_remove().

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun at 163.com>
---
 security/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/security/inode.c b/security/inode.c
index 6c326939750d..606f390d21d2 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -306,6 +306,7 @@ void securityfs_remove(struct dentry *dentry)
 			simple_rmdir(dir, dentry);
 		else
 			simple_unlink(dir, dentry);
+		d_delete(dentry);
 		dput(dentry);
 	}
 	inode_unlock(dir);
-- 
2.17.1



More information about the Linux-security-module-archive mailing list