projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
43a1711
)
printk: fix possible reuse of va_list variable
author
Tetsuo Handa
<
[email protected]
>
Fri, 11 May 2018 10:54:19 +0000
(19:54 +0900)
committer
Petr Mladek
<
[email protected]
>
Wed, 16 May 2018 12:00:46 +0000
(14:00 +0200)
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: 42a0bb3f71383b45 ("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]
>
kernel/printk/printk_safe.c
patch
|
blob
|
history
diff --git
a/kernel/printk/printk_safe.c
b/kernel/printk/printk_safe.c
index 3e3c2004bb232661bae666e00e4645fad438aee6..449d67edfa4b3e41f07277937291b6614160db26 100644
(file)
--- a/
kernel/printk/printk_safe.c
+++ b/
kernel/printk/printk_safe.c
@@
-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;