]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
tracing: Fix out of bounds write in get_trace_buf
authorQiujun Huang <hqjagain@gmail.com>
Thu, 29 Oct 2020 16:19:05 +0000 (00:19 +0800)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Mon, 2 Nov 2020 13:52:18 +0000 (08:52 -0500)
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>
kernel/trace/trace.c

index 528971714fc65d30346c6fb0f4d2d05b0457f1a3..daa96215e29486da12699fba990be5f0f78ea786 100644 (file)
@@ -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)