Re: [PATCH v1] kernel/trace/ring_buffer: don't deactivate non-existant pages

From: Steven Rostedt
Date: Thu Nov 17 2022 - 17:12:04 EST


On Mon, 14 Nov 2022 17:31:29 +0300
Daniil Tatianin <d-tatianin@xxxxxxxxxxxxxx> wrote:

> rb_head_page_deactivate() expects cpu_buffer to contain a valid list of
> ->pages, so verify that the list is actually present before calling it.
>
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
>
> Signed-off-by: Daniil Tatianin <d-tatianin@xxxxxxxxxxxxxx>
> ---
> kernel/trace/ring_buffer.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index a12e27815555..1e9de3d49701 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -1635,9 +1635,9 @@ static void rb_free_cpu_buffer(struct ring_buffer_per_cpu *cpu_buffer)
>
> free_buffer_page(cpu_buffer->reader_page);
>
> - rb_head_page_deactivate(cpu_buffer);
> -

Logically, this should never happen, but regardless, I consider this a fix.

Queued. Thanks Daniil!

-- Steve


> if (head) {
> + rb_head_page_deactivate(cpu_buffer);
> +
> list_for_each_entry_safe(bpage, tmp, head, list) {
> list_del_init(&bpage->list);
> free_buffer_page(bpage);