* [PATCH] fs/namespace: reject bufsize < sizeof(struct statmount) in prepare_kstatmount()
@ 2026-09-19 22:17 Hui Peng
0 siblings, 0 replies; only message in thread
From: Hui Peng @ 2026-09-19 22:17 UTC (permalink / raw)
To: viro, brauner, jack; +Cc: linux-fsdevel, linux-kernel
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-19 22:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-19 22:17 [PATCH] fs/namespace: reject bufsize < sizeof(struct statmount) in prepare_kstatmount() Hui Peng
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®