From: Jori Koolstra <jkoolstra@xs4all.nl>
To: Vineet Agarwal <agarwal.vineet2006@gmail.com>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot <syzbot@syzkaller.appspotmail.com>
Subject: Re: [PATCH] fs/namespace: fix NULL pointer dereference in do_lock_mount()
Date: Tue, 5 May 2026 16:43:48 +0200 [thread overview]
Message-ID: <afn88B9Z5TM-0d0T@lt-jori.localdomain> (raw)
In-Reply-To: <20260505095156.178351-1-agarwal.vineet2006@gmail.com>
On Tue, May 05, 2026 at 03:21:31PM +0530, Vineet Agarwal wrote:
> Syzkaller reported a NULL pointer dereference in do_lock_mount()
> when calling inode_lock() on a dentry without an associated inode.
>
> where_to_mount() may return a negative dentry (without an inode)
> due to concurrent unlink or mount changes. The current code does
> not validate this before calling inode_lock(), leading to a crash.
Can you explain what call path could lead to having path here refer
to a negative dentry? Is it not the case that a positive dentry's
d_inode is stable as long as you hold a reference to the dentry? If,
so it cannot be killed underneath us.
>
> Fix this by checking dentry and dentry->d_inode before acquiring
> the inode lock.
>
> Reported-by: syzbot <syzbot@syzkaller.appspotmail.com>
This is not enough. Which syzbot issue are you trying to fix?
> Closes: https://syzkaller.appspot.com/
> Signed-off-by: Vineet Agarwal <agarwal.vineet2006@gmail.com>
> ---
> fs/namespace.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/fs/namespace.c b/fs/namespace.c
> index fe919abd2f01..b1dccdf06836 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -2760,6 +2760,17 @@ static void do_lock_mount(const struct path *path,
> }
> }
>
> + if (unlikely(!dentry || !dentry->d_inode)) {
> + err = -ENOENT;
> + if (&m->mnt != path->mnt) {
> + if (dentry)
> + dput(dentry);
> + mntput(&m->mnt);
> + }
> + res->parent = ERR_PTR(err);
> + return;
> + }
> +
> inode_lock(dentry->d_inode);
> namespace_lock();
>
> --
> 2.54.0
>
Thanks,
Jori.
next prev parent reply other threads:[~2026-05-05 14:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 9:51 Vineet Agarwal
2026-05-05 14:43 ` Jori Koolstra [this message]
[not found] ` <CA+rjy8fM+8ahj7dcBWjnACU8xBWBqW4ssQFpi68dqRc-F-V3Xg@mail.gmail.com>
2026-05-06 2:12 ` Al Viro
2026-05-06 2:21 ` Al Viro
2026-05-06 4:37 ` Vineet Agarwal
2026-05-11 12:58 ` Christian Brauner
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=afn88B9Z5TM-0d0T@lt-jori.localdomain \
--to=jkoolstra@xs4all.nl \
--cc=agarwal.vineet2006@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot@syzkaller.appspotmail.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
all inboxes | Powered by JetHome®