linux/mm/kmsan
Pedro Falcato 09aec5f9b2 mm: kmsan: panic on failure to allocate early boot metadata
Given large enough allocations and a machine with low enough memory (i.e a
default QEMU VM), it's entirely possible that
kmsan_init_alloc_meta_for_range's shadow+origin allocation fails.

Instead of eating a NULL deref kernel oops, check explicitly for
memblock_alloc() failure and panic with a nice error message.

Alexander Potapenko said:

For posterity, it is generally quite important for the allocated shadow
and origin to be contiguous, otherwise an unaligned memory write may
result in memory corruption (the corresponding unaligned shadow write will
be assuming that shadow pages are adjacent).  So instead of panicking we
could have split the range into smaller ones until the allocation
succeeds, but that would've led to hard-to-debug problems in the future.

Link: https://lkml.kernel.org/r/20231016153446.132763-1-pedro.falcato@gmail.com
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-10-25 16:47:10 -07:00
..
core.c kmsan: simplify kmsan_internal_memmove_metadata() 2023-10-04 10:32:22 -07:00
hooks.c mm: kmsan: use helper macro offset_in_page() 2023-08-21 13:37:29 -07:00
init.c mm, treewide: redefine MAX_ORDER sanely 2023-04-05 19:42:46 -07:00
instrumentation.c kasan,kmsan: remove __GFP_KSWAPD_RECLAIM usage from kasan/kmsan 2023-06-23 16:59:26 -07:00
kmsan_test.c kmsan: introduce test_memcpy_initialized_gap() 2023-10-04 10:32:22 -07:00
kmsan.h kmsan: core: kmsan_in_runtime() should return true in NMI context 2022-11-08 15:57:24 -08:00
Makefile kmsan: disable ftrace in kmsan core code 2023-02-20 12:46:16 -08:00
report.c
shadow.c mm: kmsan: panic on failure to allocate early boot metadata 2023-10-25 16:47:10 -07:00