mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
kasan: enable stack instrumentation
Stack instrumentation allows to detect out of bounds memory accesses for variables allocated on stack. Compiler adds redzones around every variable on stack and poisons redzones in function's prologue. Such approach significantly increases stack usage, so all in-kernel stacks size were doubled. Signed-off-by: Andrey Ryabinin <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Konstantin Serebryany <[email protected]> Cc: Dmitry Chernenkov <[email protected]> Signed-off-by: Andrey Konovalov <[email protected]> Cc: Yuri Gribov <[email protected]> Cc: Konstantin Khlebnikov <[email protected]> Cc: Sasha Levin <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
393f203f5f
commit
c420f167db
7 changed files with 44 additions and 5 deletions
|
|
@ -12,6 +12,15 @@
|
|||
#define KASAN_KMALLOC_REDZONE 0xFC /* redzone inside slub object */
|
||||
#define KASAN_KMALLOC_FREE 0xFB /* object was freed (kmem_cache_free/kfree) */
|
||||
|
||||
/*
|
||||
* Stack redzone shadow values
|
||||
* (Those are compiler's ABI, don't change them)
|
||||
*/
|
||||
#define KASAN_STACK_LEFT 0xF1
|
||||
#define KASAN_STACK_MID 0xF2
|
||||
#define KASAN_STACK_RIGHT 0xF3
|
||||
#define KASAN_STACK_PARTIAL 0xF4
|
||||
|
||||
|
||||
struct kasan_access_info {
|
||||
const void *access_addr;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,12 @@ static void print_error_description(struct kasan_access_info *info)
|
|||
case 0 ... KASAN_SHADOW_SCALE_SIZE - 1:
|
||||
bug_type = "out of bounds access";
|
||||
break;
|
||||
case KASAN_STACK_LEFT:
|
||||
case KASAN_STACK_MID:
|
||||
case KASAN_STACK_RIGHT:
|
||||
case KASAN_STACK_PARTIAL:
|
||||
bug_type = "out of bounds on stack";
|
||||
break;
|
||||
}
|
||||
|
||||
pr_err("BUG: KASan: %s in %pS at addr %p\n",
|
||||
|
|
|
|||
Loading…
Reference in a new issue