From: Hui Peng <benquike@gmail.com>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] fs/namespace: reject bufsize < sizeof(struct statmount) in prepare_kstatmount()
Date: Sat, 19 Sep 2026 22:17:32 +0000 [thread overview]
Message-ID: <20260919221732.3707664-1-benquike@gmail.com> (raw)
In prepare_kstatmount(), kstatmount.buf_size is initialized from the
caller's bufsize argument without rejecting buffers smaller than
sizeof(struct statmount), allowing string offset calculations relative
to sizeof(struct statmount) to underflow or write past the user buffer.
Reject bufsize < sizeof(struct statmount) in prepare_kstatmount().
Fixes: 68385d77c05b ("statmount: simplify string option retrieval")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/fs/namespace.c b/fs/namespace.c
index ae5dc64f8b45..7f7905286fa6 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -5882,7 +5882,7 @@ static int prepare_kstatmount(struct kstatmount *ks, struct mnt_id_req *kreq,
ks->bufsize = bufsize;
if (ks->mask & STATMOUNT_STRING_REQ) {
- if (bufsize == sizeof(ks->sm))
+ if (bufsize <= sizeof(ks->sm))
return -EOVERFLOW;
ks->seq.buf = kvmalloc(seq_size, GFP_KERNEL_ACCOUNT);
reply other threads:[~2026-09-19 22:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260919221732.3707664-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--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
all inboxes | Powered by JetHome®