From: Richard Weinberger <richard@nod.at>
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH] fs: Detect API misuse of i_op->lookup
Date: Sun, 25 Jan 2015 22:57:40 +0100 [thread overview]
Message-ID: <1422223060-8561-1-git-send-email-richard@nod.at> (raw)
Hunting down a refcount issue in an out-of-tree filesystem uncovered
that its lookup function directly returned the dentry which was passed to it.
Add a BUG_ON() to detect such misuse in future.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/namei.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/namei.c b/fs/namei.c
index bc35b02..f8ccae6 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1370,6 +1370,7 @@ static struct dentry *lookup_real(struct inode *dir, struct dentry *dentry,
old = dir->i_op->lookup(dir, dentry, flags);
if (unlikely(old)) {
+ BUG_ON(old == dentry);
dput(dentry);
dentry = old;
}
--
2.2.2
next reply other threads:[~2015-01-25 21:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-25 21:57 Richard Weinberger [this message]
2015-01-25 22:16 ` [PATCH] fs: Detect API misuse of i_op->lookup Al Viro
2015-01-25 22:20 ` Richard Weinberger
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=1422223060-8561-1-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).