From 5ba970d87aa35b999a6f1ecb5a4b98ab9864a7fd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 19 Dec 2022 13:21:16 +0100 Subject: [PATCH] 5.4-stable patches added patches: series tracing-ring-buffer-only-do-full-wait-when-cpu-ring_buffer_all_cpus.patch --- queue-5.4/series | 1 + ...l-wait-when-cpu-ring_buffer_all_cpus.patch | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 queue-5.4/series create mode 100644 queue-5.4/tracing-ring-buffer-only-do-full-wait-when-cpu-ring_buffer_all_cpus.patch diff --git a/queue-5.4/series b/queue-5.4/series new file mode 100644 index 00000000000..fea9ff57656 --- /dev/null +++ b/queue-5.4/series @@ -0,0 +1 @@ +tracing-ring-buffer-only-do-full-wait-when-cpu-ring_buffer_all_cpus.patch diff --git a/queue-5.4/tracing-ring-buffer-only-do-full-wait-when-cpu-ring_buffer_all_cpus.patch b/queue-5.4/tracing-ring-buffer-only-do-full-wait-when-cpu-ring_buffer_all_cpus.patch new file mode 100644 index 00000000000..1fd490e5edb --- /dev/null +++ b/queue-5.4/tracing-ring-buffer-only-do-full-wait-when-cpu-ring_buffer_all_cpus.patch @@ -0,0 +1,39 @@ +From ptyadav@amazon.de Mon Dec 19 13:19:42 2022 +From: Pratyush Yadav +Date: Fri, 16 Dec 2022 14:42:41 +0100 +Subject: tracing/ring-buffer: Only do full wait when cpu != RING_BUFFER_ALL_CPUS +To: +Cc: Pratyush Yadav , Greg Kroah-Hartman , , Linux Trace Kernel , Masami Hiramatsu , Mathieu Desnoyers , Primiano Tucci , "Steven Rostedt (Google)" +Message-ID: <20221216134241.81381-1-ptyadav@amazon.de> + +From: Pratyush Yadav + +full_hit() directly uses cpu as an array index. Since +RING_BUFFER_ALL_CPUS == -1, calling full_hit() with cpu == +RING_BUFFER_ALL_CPUS will cause an invalid memory access. + +The upstream commit 42fb0a1e84ff ("tracing/ring-buffer: Have polling +block on watermark") already does this. This was missed when backporting +to v5.4.y. + +This bug was discovered and resolved using Coverity Static Analysis +Security Testing (SAST) by Synopsys, Inc. + +Fixes: e65ac2bdda54 ("tracing/ring-buffer: Have polling block on watermark") +Signed-off-by: Pratyush Yadav +Acked-by: Steven Rostedt (Google) +Signed-off-by: Greg Kroah-Hartman +--- + kernel/trace/ring_buffer.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/kernel/trace/ring_buffer.c ++++ b/kernel/trace/ring_buffer.c +@@ -727,6 +727,7 @@ __poll_t ring_buffer_poll_wait(struct ri + + if (cpu == RING_BUFFER_ALL_CPUS) { + work = &buffer->irq_work; ++ full = 0; + } else { + if (!cpumask_test_cpu(cpu, buffer->cpumask)) + return -EINVAL; -- 2.47.3