Re: [PATCH v9 4/4] ring-buffer: Prevent truncation of nr_pages / nr_subbufs
From: Steven Rostedt
Date: Thu Sep 03 2026 - 14:25:37 EST
On Thu, 3 Sep 2026 18:37:36 +0100
Vincent Donnefort <vdonnefort@xxxxxxxxxx> wrote:
> > > static bool rb_cpu_meta_valid(struct ring_buffer_cpu_meta *meta, int cpu,
> > > - struct trace_buffer *buffer, int nr_pages,
> > > + struct trace_buffer *buffer, unsigned long nr_pages,
> > > unsigned long *subbuf_mask)
> > > {
> > > - int subbuf_size = PAGE_SIZE;
> > > + unsigned long subbuf_size = PAGE_SIZE;
> >
> > Why the long? Shouldn't it be unsigned int?
>
> That is to cheat to not have to add a cast in
>
> buffers_end = meta->first_buffer + (subbuf_size * meta->nr_subbufs);
Hmm, it's only reference once in that function. We could just replace it
with using PAGE_SIZE directly.
buffers_end = meta->first_buffer + (meta->nr_subbufs * PAGE_SIZE);
-- Steve