The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] tracing: Check for overflow in buffer_subbuf_size_kb
@ 2026-11-29 13:28 Jaewon Jung
  2026-11-29 13:42 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Jaewon Jung @ 2026-11-29 13:28 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Mathieu Desnoyers
  Cc: linux-kernel, linux-trace-kernel

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 13:28 [PATCH] tracing: Check for overflow in buffer_subbuf_size_kb Jaewon Jung
2026-11-29 13:42 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox