Re: [PATCH] ring-buffer: Fix reader locking when changing the sub buffer order
From: Steven Rostedt
Date: Mon Oct 14 2024 - 18:15:07 EST
On Mon, 14 Oct 2024 16:14:16 +0200
Petr Pavlu <petr.pavlu@xxxxxxxx> wrote:
> The function ring_buffer_subbuf_order_set() updates each
> ring_buffer_per_cpu and installs new sub buffers that match the requested
> page order. This operation may be invoked concurrently with readers that
> rely on some of the modified data, such as the head bit (RB_PAGE_HEAD), or
> the ring_buffer_per_cpu.pages and reader_page pointers. However, no
> exclusive access is acquired by ring_buffer_subbuf_order_set(). Modifying
> the mentioned data while a reader also operates on them can then result in
> incorrect memory access and various crashes.
>
> Fix the problem by taking the reader_lock when updating a specific
> ring_buffer_per_cpu in ring_buffer_subbuf_order_set().
>
> Fixes: 8e7b58c27b3c ("ring-buffer: Just update the subbuffers when
> changing their allocation order") Signed-off-by: Petr Pavlu
> <petr.pavlu@xxxxxxxx>
I see you applied this on top of your cnt patch. Can you reverse the order
and add this patch first and then the cnt patch please.
This is a fix that needs to go up to mainline during the rc release. The
cnt patch is going into the next merge window.
> ---
> References:
> https://lore.kernel.org/linux-trace-kernel/20240715145141.5528-1-petr.pavlu@xxxxxxxx/
> https://lore.kernel.org/linux-trace-kernel/20241010195849.2f77cc3f@xxxxxxxxxxxxxxxxxx/
> https://lore.kernel.org/linux-trace-kernel/20241011112850.17212b25@xxxxxxxxxxxxxxxxxx/
BTW, it's also OK to add these as Link: tags in the commit message.
-- Steve
>
> base-commit: 6485cf5ea253d40d507cd71253c9568c5470cd27
> prerequisite-patch-id: 0aa81c18abaac4990d14c431e12b9e91696aa053