提交 c1acb4ac 编写于 作者: Q Qiujun Huang 提交者: Steven Rostedt (VMware)

tracing: Fix out of bounds write in get_trace_buf

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: 3d9622c1 ("tracing: Add barrier to trace_printk() buffer nesting modification")
Signed-off-by: NQiujun Huang <hqjagain@gmail.com>
Signed-off-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
上级 3cea11cd
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册