Skip to content

Commit 6ade153

Browse files
melverakpm00
authored andcommitted
kasan: use vmalloc_dump_obj() for vmalloc error reports
Since 6ee9b3d ("kasan: remove kasan_find_vm_area() to prevent possible deadlock"), more detailed info about the vmalloc mapping and the origin was dropped due to potential deadlocks. While fixing the deadlock is necessary, that patch was too quick in killing an otherwise useful feature, and did no due-diligence in understanding if an alternative option is available. Restore printing more helpful vmalloc allocation info in KASAN reports with the help of vmalloc_dump_obj(). Example report: | BUG: KASAN: vmalloc-out-of-bounds in vmalloc_oob+0x4c9/0x610 | Read of size 1 at addr ffffc900002fd7f3 by task kunit_try_catch/493 | | CPU: [...] | Call Trace: | <TASK> | dump_stack_lvl+0xa8/0xf0 | print_report+0x17e/0x810 | kasan_report+0x155/0x190 | vmalloc_oob+0x4c9/0x610 | [...] | | The buggy address belongs to a 1-page vmalloc region starting at 0xffffc900002fd000 allocated at vmalloc_oob+0x36/0x610 | The buggy address belongs to the physical page: | page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x126364 | flags: 0x200000000000000(node=0|zone=2) | raw: 0200000000000000 0000000000000000 dead000000000122 0000000000000000 | raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 | page dumped because: kasan: bad access detected | | [..] Link: https://lkml.kernel.org/r/[email protected] Fixes: 6ee9b3d ("kasan: remove kasan_find_vm_area() to prevent possible deadlock") Signed-off-by: Marco Elver <[email protected]> Suggested-by: Uladzislau Rezki <[email protected]> Acked-by: Uladzislau Rezki (Sony) <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Sebastian Andrzej Siewior <[email protected]> Cc: Yeoreum Yun <[email protected]> Cc: Yunseong Kim <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 153ad56 commit 6ade153

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mm/kasan/report.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ static void print_address_description(void *addr, u8 tag,
399399
}
400400

401401
if (is_vmalloc_addr(addr)) {
402-
pr_err("The buggy address %px belongs to a vmalloc virtual mapping\n", addr);
402+
pr_err("The buggy address belongs to a");
403+
if (!vmalloc_dump_obj(addr))
404+
pr_cont(" vmalloc virtual mapping\n");
403405
page = vmalloc_to_page(addr);
404406
}
405407

0 commit comments

Comments
 (0)