FAILED: patch "[PATCH] mm/kfence: fix KASAN hardware tag faults during late" failed to apply to 6.6-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x d155aab90fffa00f93cea1f107aef0a3d548b2ff
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026031725-satisfied-thrower-61b1@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d155aab90fffa00f93cea1f107aef0a3d548b2ff Mon Sep 17 00:00:00 2001
From: Alexander Potapenko <[email protected]>
Date: Fri, 20 Feb 2026 15:49:40 +0100
Subject: [PATCH] mm/kfence: fix KASAN hardware tag faults during late
enablement
When KASAN hardware tags are enabled, re-enabling KFENCE late (via /sys/module/kfence/parameters/sample_interval) causes KASAN faults.
This happens because the KFENCE pool and metadata are allocated via the page allocator, which tags the memory, while KFENCE continues to access it using untagged pointers during initialization.
Use __GFP_SKIP_KASAN for late KFENCE pool and metadata allocations to ensure the memory remains untagged, consistent with early allocations from memblock. To support this, add __GFP_SKIP_KASAN to the allowlist in __alloc_contig_verify_gfp_mask().
mm/kfence/core.c +8 -6
@@ -1004,14 +1004,14 @@ static int kfence_init_late(void)#ifdef CONFIG_CONTIG_ALLOC struct page *pages; - pages =alloc_contig_pages (nr_pages_pool,GFP_KERNEL , first_online_node, -NULL ); + pages =alloc_contig_pages (nr_pages_pool,GFP_KERNEL | __GFP_SKIP_KASAN, + first_online_node,NULL );if (!pages)return -ENOMEM ; __kfence_pool =page_to_virt (pages); - pages =alloc_contig_pages (nr_pages_meta,GFP_KERNEL , first_online_node, -NULL ); + pages =alloc_contig_pages (nr_pages_meta,GFP_KERNEL | __GFP_SKIP_KASAN, + first_online_node,NULL );if (pages) kfence_metadata_init =page_to_virt (pages);#else
@@ -1021,11 +1021,13 @@ static int kfence_init_late(void) return -EINVAL; } - __kfence_pool =alloc_pages_exact (KFENCE_POOL_SIZE ,GFP_KERNEL ); + __kfence_pool =alloc_pages_exact (KFENCE_POOL_SIZE , +GFP_KERNEL | __GFP_SKIP_KASAN);if (!__kfence_pool)return -ENOMEM ; - kfence_metadata_init =alloc_pages_exact (KFENCE_METADATA_SIZE ,GFP_KERNEL ); + kfence_metadata_init =alloc_pages_exact (KFENCE_METADATA_SIZE , +GFP_KERNEL | __GFP_SKIP_KASAN);#endif if (!kfence_metadata_init)
mm/page_alloc.c +2 -1
@@ -6928,7 +6928,8 @@ static int __alloc_contig_verify_gfp_mask(gfp_t gfp_mask, gfp_t *gfp_cc_mask) {const gfp_t reclaim_mask = __GFP_IO | __GFP_FS | __GFP_RECLAIM;const gfp_t action_mask = __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWARN | - __GFP_ZERO | __GFP_ZEROTAGS | __GFP_SKIP_ZERO; + __GFP_ZERO | __GFP_ZEROTAGS | __GFP_SKIP_ZERO | + __GFP_SKIP_KASAN;const gfp_t cc_action_mask = __GFP_RETRY_MAYFAIL | __GFP_NOWARN;/*
Sasha Levin
maintainerPATCH 1/1 mm/kfence: fix KASAN hardware tag faults during late enablement
From: Alexander Potapenko <[email protected]>
[ Upstream commit d155aab90fffa00f93cea1f107aef0a3d548b2ff ]
When KASAN hardware tags are enabled, re-enabling KFENCE late (via /sys/module/kfence/parameters/sample_interval) causes KASAN faults.
This happens because the KFENCE pool and metadata are allocated via the page allocator, which tags the memory, while KFENCE continues to access it using untagged pointers during initialization.
Use __GFP_SKIP_KASAN for late KFENCE pool and metadata allocations to ensure the memory remains untagged, consistent with early allocations from memblock. To support this, add __GFP_SKIP_KASAN to the allowlist in __alloc_contig_verify_gfp_mask().
--- mm/kfence/core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
mm/kfence/core.c +8 -6
@@ -930,14 +930,14 @@ static int kfence_init_late(void)#ifdef CONFIG_CONTIG_ALLOC struct page *pages; - pages =alloc_contig_pages (nr_pages_pool,GFP_KERNEL , first_online_node, -NULL ); + pages =alloc_contig_pages (nr_pages_pool,GFP_KERNEL | __GFP_SKIP_KASAN, + first_online_node,NULL );if (!pages)return -ENOMEM ; __kfence_pool =page_to_virt (pages); - pages =alloc_contig_pages (nr_pages_meta,GFP_KERNEL , first_online_node, -NULL ); + pages =alloc_contig_pages (nr_pages_meta,GFP_KERNEL | __GFP_SKIP_KASAN, + first_online_node,NULL );if (pages) kfence_metadata_init =page_to_virt (pages);#else
@@ -947,11 +947,13 @@ static int kfence_init_late(void) return -EINVAL; } - __kfence_pool =alloc_pages_exact (KFENCE_POOL_SIZE ,GFP_KERNEL ); + __kfence_pool =alloc_pages_exact (KFENCE_POOL_SIZE , +GFP_KERNEL | __GFP_SKIP_KASAN);if (!__kfence_pool)return -ENOMEM ; - kfence_metadata_init =alloc_pages_exact (KFENCE_METADATA_SIZE ,GFP_KERNEL ); + kfence_metadata_init =alloc_pages_exact (KFENCE_METADATA_SIZE , +GFP_KERNEL | __GFP_SKIP_KASAN);#endif if (!kfence_metadata_init)
Signature · 1 line
2.51.0