From: Kees Cook <keescook@chromium.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] securityfs: Add missing d_delete() call on removal
Date: Tue, 5 May 2020 16:40:35 -0700 [thread overview]
Message-ID: <202005051626.7648DC65@keescook> (raw)
After using simple_unlink(), a call to d_delete() is needed in addition
to dput().
Signed-off-by: Kees Cook <keescook@chromium.org>
---
Is this correct? I went looking around and there are a lot of variations
on the simple_unlink() pattern...
Many using explicit locking and combinations of d_drop(), __d_drop(), etc.
Some missing d_delete()?
security/inode.c: simple_unlink(dir, dentry);
security/inode.c- d_delete(dentry);
security/inode.c- dput(dentry);
--
arch/powerpc/platforms/cell/spufs/inode.c: simple_unlink(d_inode(dir), dentry);
arch/powerpc/platforms/cell/spufs/inode.c- /* XXX: what was dcache_lock protecting here? Other
arch/powerpc/platforms/cell/spufs/inode.c- * filesystems (IB, configfs) release dcache_lock
arch/powerpc/platforms/cell/spufs/inode.c- * before unlink */
arch/powerpc/platforms/cell/spufs/inode.c- dput(dentry);
Should use d_delete() instead of d_drop()?
arch/s390/hypfs/inode.c: simple_unlink(d_inode(parent), dentry);
arch/s390/hypfs/inode.c- }
arch/s390/hypfs/inode.c- d_drop(dentry);
arch/s390/hypfs/inode.c- dput(dentry);
arch/s390/hypfs/inode.c- inode_unlock(d_inode(parent));
arch/s390/hypfs/inode.c-}
Correct?
drivers/android/binderfs.c: simple_unlink(parent_inode, dentry);
drivers/android/binderfs.c- d_delete(dentry);
drivers/android/binderfs.c- dput(dentry);
--
fs/nfsd/nfsctl.c: ret = simple_unlink(dir, dentry);
fs/nfsd/nfsctl.c- d_delete(dentry);
fs/nfsd/nfsctl.c- dput(dentry);
--
net/sunrpc/rpc_pipe.c: ret = simple_unlink(dir, dentry);
net/sunrpc/rpc_pipe.c- if (!ret)
net/sunrpc/rpc_pipe.c- fsnotify_unlink(dir, dentry);
net/sunrpc/rpc_pipe.c- d_delete(dentry);
net/sunrpc/rpc_pipe.c- dput(dentry);
--
security/apparmor/apparmorfs.c: simple_unlink(dir, dentry);
security/apparmor/apparmorfs.c- d_delete(dentry);
security/apparmor/apparmorfs.c- dput(dentry);
---
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.20.1
--
Kees Cook
next reply other threads:[~2020-05-05 23:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 23:40 Kees Cook [this message]
2020-05-06 1:14 ` [PATCH] securityfs: Add missing d_delete() call on removal Al Viro
2020-05-06 3:28 ` Kees Cook
2020-05-06 4:02 ` Al Viro
2020-05-06 15:34 ` Kees Cook
2020-05-06 18:49 ` Al Viro
2020-05-06 22:49 ` Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202005051626.7648DC65@keescook \
--to=keescook@chromium.org \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).