mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 03:50:24 +09:00
printk: fix possible reuse of va_list variable
commit988a35f8daupstream. I noticed that there is a possibility that printk_safe_log_store() causes kernel oops because "args" parameter is passed to vsnprintf() again when atomic_cmpxchg() detected that we raced. Fix this by using va_copy(). Link: http://lkml.kernel.org/r/201805112002.GIF21216.OFVHFOMLJtQFSO@I-love.SAKURA.ne.jp Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: dvyukov@google.com Cc: syzkaller@googlegroups.com Cc: fengguang.wu@intel.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Fixes:42a0bb3f71("printk/nmi: generic solution for safe printk in NMI") Cc: 4.7+ <stable@vger.kernel.org> # v4.7+ Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ca558fb836
commit
db2baeef79
@@ -63,6 +63,7 @@ static int vprintk_nmi(const char *fmt, va_list args)
|
||||
struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
|
||||
int add = 0;
|
||||
size_t len;
|
||||
va_list ap;
|
||||
|
||||
again:
|
||||
len = atomic_read(&s->len);
|
||||
@@ -79,7 +80,9 @@ again:
|
||||
if (!len)
|
||||
smp_rmb();
|
||||
|
||||
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
|
||||
va_copy(ap, args);
|
||||
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/*
|
||||
* Do it once again if the buffer has been flushed in the meantime.
|
||||
|
||||
Reference in New Issue
Block a user