From: Jaewon Jung <jaewon8868@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH] tracing: Check for overflow in buffer_subbuf_size_kb
Date: Sun, 29 Nov 2026 22:28:56 +0900 [thread overview]
Message-ID: <20261129132918.852689-1-jaewon8868@gmail.com> (raw)
The KB-to-bytes conversion in buffer_subbuf_size_write() can overflow and
wrap a huge request to a small value, which then passes the page-order
limit and sets an unintended sub-buffer size. Check for it before the
multiplication.
Fixes: 2f84b39f4847 ("tracing: Update subbuffer with kilobytes not page order")
Signed-off-by: Jaewon Jung <jaewon8868@gmail.com>
---
kernel/trace/trace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 65b9d67647e5..45cffadd52f6 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -8337,6 +8337,9 @@ buffer_subbuf_size_write(struct file *filp, const char __user *ubuf,
if (ret)
return ret;
+ /* Reject values that would overflow when converted to bytes. */
+ if (val > ULONG_MAX / 1024)
+ return -EINVAL;
val *= 1024; /* value passed in is in KB */
pages = DIV_ROUND_UP(val, PAGE_SIZE);
--
2.43.0
next reply other threads:[~2026-11-29 13:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 13:28 Jaewon Jung [this message]
2026-11-29 13:38 ` [PATCH] tracing: Check for overflow in buffer_subbuf_size_kb sashiko-bot
2026-11-29 13:42 ` Steven Rostedt
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=20261129132918.852689-1-jaewon8868@gmail.com \
--to=jaewon8868@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
/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.