tracing: Fix out of bounds write in get_trace_buf
PATCH v4 1/1 tracing: Fix out of bounds write in get_trace_buf
The subscript should be nesting - 1, as nesting had self-added.
Fixes 3d9622c12c887 ("tracing: Add barrier to trace_printk() buffer nesting modification")
Signed-off-by Qiujun Huang <[email protected]>
---
v4:
Find the right patch which cause the problem.
v3:
Modify the way of array reference instead.
v2:
Fix a typo in the title.
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -3132,7 +3132,7 @@ static char *get_trace_buf(void)/* Interrupts must see nesting incremented before we use the buffer */ barrier (); -return &buffer->buffer[buffer->nesting][0 ]; +return &buffer->buffer[buffer->nesting -1 ][0 ]; }static void put_trace_buf (void )
Signature · 1 line
2.17.1
Steven Rostedt
maintainerQuoted 3 lines · On Fri, 30 Oct 2020 00:19:05 +0800 Qiujun Huang <[email protected]> wrote:
The subscript should be nesting - 1, as nesting had self-added.
Fixes 3d9622c12c887 ("tracing: Add barrier to trace_printk() buffer nesting modification")
Thanks, I'll still use the updated change log.
-- Steve
Quoted 25 lines
Signed-off-by Qiujun Huang <[email protected]>---
v4:
Find the right patch which cause the problem.
v3:
Modify the way of array reference instead.
v2:
Fix a typo in the title.--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/trace/trace.c +1
-1@@ -3132,7 +3132,7 @@ static char *get_trace_buf(void)/* Interrupts must see nesting incremented before we use the buffer */ barrier (); -return &buffer->buffer[buffer->nesting][0 ]; +return &buffer->buffer[buffer->nesting -1 ][0 ]; }static void put_trace_buf (void )