]> git.baikalelectronics.ru Git - kernel.git/commit
x86/entry/64: Wipe KASAN stack shadow before rewind_stack_do_exit()
authorJann Horn <jannh@google.com>
Tue, 28 Aug 2018 18:40:33 +0000 (20:40 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 30 Aug 2018 09:37:09 +0000 (11:37 +0200)
commitc78077c404bdaa06d324ec23ba42859471c02b2c
tree98e211b55e3cea0a12af6410dd21a9312eb130d4
parent34eb9a60651e0e6e555424d731263d3a822c5760
x86/entry/64: Wipe KASAN stack shadow before rewind_stack_do_exit()

Reset the KASAN shadow state of the task stack before rewinding RSP.
Without this, a kernel oops will leave parts of the stack poisoned, and
code running under do_exit() can trip over such poisoned regions and cause
nonsensical false-positive KASAN reports about stack-out-of-bounds bugs.

This does not wipe the exception stacks; if an oops happens on an exception
stack, it might result in random KASAN false-positives from other tasks
afterwards. This is probably relatively uninteresting, since if the kernel
oopses on an exception stack, there are most likely bigger things to worry
about. It'd be more interesting if vmapped stacks and KASAN were
compatible, since then handle_stack_overflow() would oops from exception
stack context.

Fixes: 5c45f29b56f9 ("x86/dumpstack: When OOPSing, rewind the stack before do_exit()")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: kasan-dev@googlegroups.com
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20180828184033.93712-1-jannh@google.com
arch/x86/kernel/dumpstack.c