9p: don't WARN_ONCE on racy symlink fid lookup failure
PATCH 1/1 9p: don't WARN_ONCE on racy symlink fid lookup failure
v9fs_init_request() WARN_ONCE()s when v9fs_fid_lookup() fails for a symlink read via the page cache. This is a benign TOCTOU race: a concurrent unlink()/rename() can remove the target between the walk finding the dentry and p9_client_walk() completing, so the lookup legitimately fails with -ENOENT (observed: dentry=/file0, err=-2).
With panic_on_warn=1, this WARN escalates to a full kernel panic -- an unprivileged local DoS reachable by racing mount() against a concurrent unlink/rename.
Return the error directly instead of WARN_ONCE().
--- fs/9p/vfs_addr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/9p/vfs_addr.c +4 -1
@@ -140,13 +140,16 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file) goto no_fid;p9_fid_get (fid); }else if (S_ISLNK (rreq->inode->i_mode)) { +/* racing unlink/rename can make this fail with -ENOENT; +* that's expected, not a kernel bug, so don't WARN +*/ dentry =d_find_any_alias (rreq->inode);if (!dentry) goto no_fid; fid =v9fs_fid_lookup (dentry);dput (dentry);if (IS_ERR (fid)) - goto no_fid; +return PTR_ERR (fid); }else { fid =v9fs_fid_find_inode (rreq->inode, writing,INVALID_UID , true);if (!fid)
Signature · 1 line
2.43.0
Quoted 43 lines · Deepanshu Kartikey
v9fs_init_request()WARN_ONCE()s whenv9fs_fid_lookup()fails for a symlink read via the page cache. This is a benign TOCTOU race: a concurrent unlink()/rename() can remove the target between the walk finding the dentry andp9_client_walk()completing, so the lookup legitimately fails with-ENOENT(observed: dentry=/file0, err=-2).With panic_on_warn=1, this WARN escalates to a full kernel panic -- an unprivileged local DoS reachable by racing
mount()against a concurrent unlink/rename.Return the error directly instead of
WARN_ONCE().Reported-by [email protected]Signed-off-by Deepanshu Kartikey <[email protected]>--- fs/9p/vfs_addr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/9p/vfs_addr.c +4
-2@@ -140,13 +140,16 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file) goto no_fid;p9_fid_get (fid); }else if (S_ISLNK (rreq->inode->i_mode)) { +/* racing unlink/rename can make this fail with -ENOENT; +* that's expected, not a kernel bug, so don't WARN +*/ dentry =d_find_any_alias (rreq->inode);if (!dentry) goto no_fid; fid =v9fs_fid_lookup (dentry);dput (dentry);if (IS_ERR (fid)) - goto no_fid; +return PTR_ERR (fid); }else { fid =v9fs_fid_find_inode (rreq->inode, writing,INVALID_UID , true);if (!fid) --
Quoted 2 lines
2.43.0
Gentle Reminder. Let me know anythng else needed from my side.
Thanks
Deepanshu
Quoted 43 lines · Deepanshu Kartikey
v9fs_init_request()WARN_ONCE()s whenv9fs_fid_lookup()fails for a symlink read via the page cache. This is a benign TOCTOU race: a concurrent unlink()/rename() can remove the target between the walk finding the dentry andp9_client_walk()completing, so the lookup legitimately fails with-ENOENT(observed: dentry=/file0, err=-2).With panic_on_warn=1, this WARN escalates to a full kernel panic -- an unprivileged local DoS reachable by racing
mount()against a concurrent unlink/rename.Return the error directly instead of
WARN_ONCE().Reported-by [email protected]Signed-off-by Deepanshu Kartikey <[email protected]>--- fs/9p/vfs_addr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)fs/9p/vfs_addr.c +4
-2@@ -140,13 +140,16 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file) goto no_fid;p9_fid_get (fid); }else if (S_ISLNK (rreq->inode->i_mode)) { +/* racing unlink/rename can make this fail with -ENOENT; +* that's expected, not a kernel bug, so don't WARN +*/ dentry =d_find_any_alias (rreq->inode);if (!dentry) goto no_fid; fid =v9fs_fid_lookup (dentry);dput (dentry);if (IS_ERR (fid)) - goto no_fid; +return PTR_ERR (fid); }else { fid =v9fs_fid_find_inode (rreq->inode, writing,INVALID_UID , true);if (!fid) --
Quoted 2 lines
2.43.0
Gentle Reminder. Let me know anythng else needed from my side.
Thanks
Deepanshu
Dominique Martinet
maintainerDeepanshu Kartikey wrote on Sat, Jul 25, 2026 at 07:14:48AM +0530:
Quoted 10 lines
v9fs_init_request()WARN_ONCE()s whenv9fs_fid_lookup()fails for a symlink read via the page cache. This is a benign TOCTOU race: a concurrent unlink()/rename() can remove the target between the walk finding the dentry andp9_client_walk()completing, so the lookup legitimately fails with-ENOENT(observed: dentry=/file0, err=-2).With panic_on_warn=1, this WARN escalates to a full kernel panic -- an unprivileged local DoS reachable by racing
mount()against a concurrent unlink/rename.
Quoted 5 lines
Return the error directly instead of
WARN_ONCE().Reported-by [email protected]Signed-off-by Deepanshu Kartikey <[email protected]>
Fair enough, picked up for 7.4
Signature · 1 line
Dominique Martinet | Asmadeus