Skip to content

Commit 0358022

Browse files
Qiujun Huanggregkh
authored andcommitted
tracing: Fix out of bounds write in get_trace_buf
commit c1acb4a upstream. The nesting count of trace_printk allows for 4 levels of nesting. The nesting counter starts at zero and is incremented before being used to retrieve the current context's buffer. But the index to the buffer uses the nesting counter after it was incremented, and not its original number, which in needs to do. Link: https://lkml.kernel.org/r/20201029161905.4269-1-hqjagain@gmail.com Cc: stable@vger.kernel.org Fixes: 3d9622c ("tracing: Add barrier to trace_printk() buffer nesting modification") Signed-off-by: Qiujun Huang <hqjagain@gmail.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d42bafd commit 0358022

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/trace/trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3114,7 +3114,7 @@ static char *get_trace_buf(void)
31143114

31153115
/* Interrupts must see nesting incremented before we use the buffer */
31163116
barrier();
3117-
return &buffer->buffer[buffer->nesting][0];
3117+
return &buffer->buffer[buffer->nesting - 1][0];
31183118
}
31193119

31203120
static void put_trace_buf(void)

0 commit comments

Comments
 (0)