[PATCH] kasan, mm: fix crash with HW_TAGS and DEBUG_PAGEALLOC
Andrey Konovalov
andreyknvl at google.com
Thu Feb 25 20:25:37 EST 2021
Currently, kasan_free_nondeferred_pages()->kasan_free_pages() is called
after debug_pagealloc_unmap_pages(). This causes a crash when
debug_pagealloc is enabled, as HW_TAGS KASAN can't set tags on an
unmapped page.
This patch puts kasan_free_nondeferred_pages() before
debug_pagealloc_unmap_pages().
Besides fixing the crash, this also makes the annotation order consistent
with debug_pagealloc_map_pages() preceding kasan_alloc_pages().
Signed-off-by: Andrey Konovalov <andreyknvl at google.com>
---
mm/page_alloc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index c89e7b107514..54bc237fd319 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1311,10 +1311,14 @@ static __always_inline bool free_pages_prepare(struct page *page,
*/
arch_free_page(page, order);
- debug_pagealloc_unmap_pages(page, 1 << order);
-
+ /*
+ * With hardware tag-based KASAN, memory tags must be set
+ * before unmapping the page with debug_pagealloc.
+ */
kasan_free_nondeferred_pages(page, order, fpi_flags);
+ debug_pagealloc_unmap_pages(page, 1 << order);
+
return true;
}
--
2.30.1.766.gb4fecdf3b7-goog
More information about the linux-arm-kernel
mailing list