From: Hui Peng <benquike@gmail.com>
To: ericvh@kernel.org, lucho@ionkov.net, asmadeus@codewreck.org,
linux_oss@crudebyte.com
Cc: v9fs@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH] 9p: reject RERROR/RLERROR with zero errcode and guard 0-link drop_nlink()
Date: Sat, 19 Sep 2026 22:17:34 +0000 [thread overview]
Message-ID: <20260919221734.3708000-1-benquike@gmail.com> (raw)
Fix two issues in 9p client and VFS inode handling:
1. In p9_check_errors() (net/9p/client.c), a malicious or buggy 9p
server returning P9_RERROR or P9_RLERROR with ecode == 0 causes
p9_check_errors() to return 0 (success) while leaving the unparsed
response payload as if the expected reply message type succeeded. Map
ecode == 0 on RERROR / RLERROR to -EPROTO.
2. In v9fs_dec_count() (fs/9p/vfs_inode.c), only call drop_nlink() when
inode->i_nlink > 0 so unlinking an inode whose server-reported nlink
was already 0 does not underflow i_nlink and trigger
WARN_ON(inode->i_nlink == 0).
Fixes: bd238fb431f3 ("9p: Reorganization of 9p file system code")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 3829554ca369..12db5ff61554 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -503,7 +503,7 @@ static void v9fs_dec_count(struct inode *inode)
if (!(v9ses->cache & (CACHE_META | CACHE_LOOSE)))
return;
- if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2)
+ if (S_ISDIR(inode->i_mode) ? inode->i_nlink > 2 : inode->i_nlink > 0)
drop_nlink(inode);
}
diff --git a/net/9p/client.c b/net/9p/client.c
index ef64546c6d52..e63e8c2a853d 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -448,6 +448,9 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
p9_debug(P9_DEBUG_9P, "<<< RLERROR (%d)\n", -ecode);
}
+ if (!err)
+ err = -EPROTO;
+
return err;
out_err:
next reply other threads:[~2026-09-19 22:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 22:17 Hui Peng [this message]
2026-09-22 8:47 ` [PATCH] 9p: reject RERROR/RLERROR with zero errcode and guard 0-link drop_nlink() Dominique Martinet
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=20260919221734.3708000-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=asmadeus@codewreck.org \
--cc=ericvh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=v9fs@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.