From: Vineet Agarwal <agarwal.vineet2006@gmail.com>
To: viro@zeniv.linux.org.uk
Cc: brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vineet Agarwal <agarwal.vineet2006@gmail.com>,
syzbot <syzbot@syzkaller.appspotmail.com>
Subject: [PATCH] fs/namespace: fix NULL pointer dereference in do_lock_mount()
Date: Tue, 5 May 2026 15:21:31 +0530 [thread overview]
Message-ID: <20260505095156.178351-1-agarwal.vineet2006@gmail.com> (raw)
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.
Fix this by checking dentry and dentry->d_inode before acquiring
the inode lock.
Reported-by: syzbot <syzbot@syzkaller.appspotmail.com>
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
next reply other threads:[~2026-05-05 9:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 9:51 Vineet Agarwal [this message]
2026-05-05 14:43 ` [PATCH] fs/namespace: fix NULL pointer dereference in do_lock_mount() Jori Koolstra
[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
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=20260505095156.178351-1-agarwal.vineet2006@gmail.com \
--to=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