mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
printk: fix possible reuse of va_list variable
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/[email protected]
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Tetsuo Handa <[email protected]>
Fixes: 42a0bb3f71 ("printk/nmi: generic solution for safe printk in NMI")
Cc: 4.7+ <[email protected]> # v4.7+
Reviewed-by: Sergey Senozhatsky <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
This commit is contained in:
parent
43a17111c2
commit
988a35f8da
1 changed files with 4 additions and 1 deletions
|
|
@ -82,6 +82,7 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s,
|
|||
{
|
||||
int add;
|
||||
size_t len;
|
||||
va_list ap;
|
||||
|
||||
again:
|
||||
len = atomic_read(&s->len);
|
||||
|
|
@ -100,7 +101,9 @@ again:
|
|||
if (!len)
|
||||
smp_rmb();
|
||||
|
||||
add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
|
||||
va_copy(ap, args);
|
||||
add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap);
|
||||
va_end(ap);
|
||||
if (!add)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue