mm: kmsan: handle alloc failures in kmsan_ioremap_page_range()
authorAlexander Potapenko <glider@google.com>
Thu, 13 Apr 2023 13:12:21 +0000 (15:12 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 18 Apr 2023 21:22:13 +0000 (14:22 -0700)
commitfdea03e12aa2a44a7bb34144208be97fc25dfd90
treecf4d990b76d490372ef63e6ef37a24af277a06f2
parent47ebd0310e89c087f56e58c103c44b72a2f6b216
mm: kmsan: handle alloc failures in kmsan_ioremap_page_range()

Similarly to kmsan_vmap_pages_range_noflush(), kmsan_ioremap_page_range()
must also properly handle allocation/mapping failures.  In the case of
such, it must clean up the already created metadata mappings and return an
error code, so that the error can be propagated to ioremap_page_range().
Without doing so, KMSAN may silently fail to bring the metadata for the
page range into a consistent state, which will result in user-visible
crashes when trying to access them.

Link: https://lkml.kernel.org/r/20230413131223.4135168-2-glider@google.com
Fixes: b073d7f8aee4 ("mm: kmsan: maintain KMSAN metadata for page operations")
Signed-off-by: Alexander Potapenko <glider@google.com>
Reported-by: Dipanjan Das <mail.dipanjan.das@gmail.com>
Link: https://lore.kernel.org/linux-mm/CANX2M5ZRrRA64k0hOif02TjmY9kbbO2aCBPyq79es34RXZ=cAw@mail.gmail.com/
Reviewed-by: Marco Elver <elver@google.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Uladzislau Rezki (Sony) <urezki@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/kmsan.h
mm/kmsan/hooks.c
mm/vmalloc.c