Re: [PATCH v5 10/10] ring-buffer: Make nr_pages unsigned int

From
Steven Rostedt <rostedt@goodmis.org>
Date
2026-08-14 01:41:42
Also in
sashiko-reviews
Reply to
sashiko-bot@kernel.org, 2026-08-13
On Thu, 13 Aug 2026 13:55:26 +0000
sashiko-bot@kernel.org wrote:
quoted
@@ -3264,7 +3263,7 @@ int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
 			int cpu_id)
 {
 	struct ring_buffer_per_cpu *cpu_buffer;
-	unsigned long nr_pages;
+	unsigned int nr_pages;  
[Severity: Critical]
If a huge value is written to buffer_size_kb, could the unsigned
difference between nr_pages and cpu_buffer->nr_pages overflow when
assigned to the now 32-bit signed cpu_buffer->nr_pages_to_update?
I agree. I never wanted to limit the size of the ring buffer. If anything,
I would want to make all references to nr_pages to be long. Otherwise we
are capping the size of the ring buffer to 8 terabytes per CPU. Yeah, that
may sound huge, but believe me, in the not so distant future, it may be
desirable.

I'm fine with keeping persistent memory and even special case mappings
limited to MAX_INT pages. But not the ring buffer as a whole.

-- Steve
Thread (52 messages) 52 messages, 7 authors, last reply 2026-09-03
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help