The quilt patch titled Subject: kasan: reset page tags properly with sampling has been removed from the -mm tree. Its filename was kasan-reset-page-tags-properly-with-sampling.patch This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm ------------------------------------------------------ From: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Subject: kasan: reset page tags properly with sampling Date: Tue, 24 Jan 2023 21:35:26 +0100 The implementation of page_alloc poisoning sampling assumed that tag_clear_highpage resets page tags for __GFP_ZEROTAGS allocations. However, this is no longer the case since commit 70c248aca9e7 ("mm: kasan: Skip unpoisoning of user pages"). This leads to kernel crashes when MTE-enabled userspace mappings are used with Hardware Tag-Based KASAN enabled. Reset page tags for __GFP_ZEROTAGS allocations in post_alloc_hook(). Also clarify and fix related comments. [andreyknvl@xxxxxxxxxx: update comment] Link: https://lkml.kernel.org/r/5dbd866714b4839069e2d8469ac45b60953db290.1674592780.git.andreyknvl@xxxxxxxxxx Link: https://lkml.kernel.org/r/24ea20c1b19c2b4b56cf9f5b354915f8dbccfc77.1674592496.git.andreyknvl@xxxxxxxxxx Fixes: 44383cef54c0 ("kasan: allow sampling page_alloc allocations for HW_TAGS") Signed-off-by: Andrey Konovalov <andreyknvl@xxxxxxxxxx> Reported-by: Peter Collingbourne <pcc@xxxxxxxxxx> Tested-by: Peter Collingbourne <pcc@xxxxxxxxxx> Cc: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Andrey Ryabinin <ryabinin.a.a@xxxxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Marco Elver <elver@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/mm/page_alloc.c~kasan-reset-page-tags-properly-with-sampling +++ a/mm/page_alloc.c @@ -2476,7 +2476,7 @@ inline void post_alloc_hook(struct page bool init = !want_init_on_free() && want_init_on_alloc(gfp_flags) && !should_skip_init(gfp_flags); bool zero_tags = init && (gfp_flags & __GFP_ZEROTAGS); - bool reset_tags = !zero_tags; + bool reset_tags = true; int i; set_page_private(page, 0); @@ -2503,7 +2503,7 @@ inline void post_alloc_hook(struct page * (which happens only when memory should be initialized as well). */ if (zero_tags) { - /* Initialize both memory and tags. */ + /* Initialize both memory and memory tags. */ for (i = 0; i != 1 << order; ++i) tag_clear_highpage(page + i); @@ -2521,14 +2521,15 @@ inline void post_alloc_hook(struct page } else { /* * KASAN decided to exclude this allocation from being - * poisoned due to sampling. Skip poisoning as well. + * (un)poisoned due to sampling. Make KASAN skip + * poisoning when the allocation is freed. */ SetPageSkipKASanPoison(page); } } /* - * If memory tags have not been set, reset the page tags to ensure - * page_address() dereferencing does not fault. + * If memory tags have not been set by KASAN, reset the page tags to + * ensure page_address() dereferencing does not fault. */ if (reset_tags) { for (i = 0; i != 1 << order; ++i) _ Patches currently in -mm which might be from andreyknvl@xxxxxxxxxx are lib-stackdepot-fix-setting-next_slab_inited-in-init_stack_slab.patch lib-stackdepot-put-functions-in-logical-order.patch lib-stackdepot-use-pr_fmt-to-define-message-format.patch lib-stackdepot-mm-rename-stack_depot_want_early_init.patch lib-stackdepot-rename-stack_depot_disable.patch lib-stackdepot-annotate-init-and-early-init-functions.patch lib-stackdepot-lower-the-indentation-in-stack_depot_init.patch lib-stackdepot-reorder-and-annotate-global-variables.patch lib-stackdepot-rename-hash-table-constants-and-variables.patch lib-stackdepot-rename-init_stack_slab.patch lib-stackdepot-rename-slab-variables.patch lib-stackdepot-rename-handle-and-slab-constants.patch lib-stacktrace-drop-impossible-warn_on-for-depot_init_slab.patch lib-stackdepot-annotate-depot_init_slab-and-depot_alloc_stack.patch lib-stacktrace-kasan-kmsan-rework-extra_bits-interface.patch lib-stackdepot-annotate-racy-slab_index-accesses.patch lib-stackdepot-various-comments-clean-ups.patch lib-stackdepot-move-documentation-comments-to-stackdepoth.patch