From: Walter Wu
mainline inclusion
from mainline-5.11-rc2
commit 13384f6125ad7ebdcc8914fe1e03ded48ce76581
category: bugfix
issue: #I3ZXZF
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
---------------------------
Syzbot reported the following [1]:
BUG: kernel NULL pointer dereference, address: 0000000000000008
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 2d993067 P4D 2d993067 PUD 19a3c067 PMD 0
Oops: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 3852 Comm: kworker/1:2 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events free_ipc
RIP: 0010:kasan_record_aux_stack+0x77/0xb0
Add null checking slab object from kasan_get_alloc_meta() in order to
avoid null pointer dereference.
[1] https://syzkaller.appspot.com/x/log.txt?x=10a82a50d00000
Link: https://lkml.kernel.org/r/20201228080018.23041-1-walter-zh.wu@mediatek.com
Signed-off-by: Walter Wu
Suggested-by: Dmitry Vyukov
Cc: Andrey Ryabinin
Cc: Dmitry Vyukov
Cc: Andrey Konovalov
Cc: Alexander Potapenko
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
Signed-off-by: Chengyang Fan
Reviewed-by: Kefeng Wang
Signed-off-by: Chen Jun
Signed-off-by: Yu Changchun
---
mm/kasan/generic.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
index 248264b9cb76..2efc48444e77 100644
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -338,6 +338,8 @@ void kasan_record_aux_stack(void *addr)
cache = page->slab_cache;
object = nearest_obj(cache, page, addr);
alloc_info = get_alloc_info(cache, object);
+ if (!alloc_info)
+ return;
/*
* record the last two call_rcu() call stacks.
--
2.22.0