diff options
author | Qiujun Huang <hqjagain@gmail.com> | 2020-10-30 00:19:05 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-11-10 12:35:58 +0100 |
commit | 7e4eeff7da1df5602e9af340d01b2ce1b4662d3e (patch) | |
tree | b0b82ef58817a71bee8ec4c3a4180bfc6d70cc33 | |
parent | 2de780dfbe1ad05c3f15f8d6f2d22dae9cf95267 (diff) | |
download | linux-stable-7e4eeff7da1df5602e9af340d01b2ce1b4662d3e.tar.gz linux-stable-7e4eeff7da1df5602e9af340d01b2ce1b4662d3e.tar.bz2 linux-stable-7e4eeff7da1df5602e9af340d01b2ce1b4662d3e.zip |
tracing: Fix out of bounds write in get_trace_buf
commit c1acb4ac1a892cf08d27efcb964ad281728b0545 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: 3d9622c12c887 ("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>
-rw-r--r-- | kernel/trace/trace.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 6bf617ff0369..c3cc6aaa6f79 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2819,7 +2819,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) |