[PATCH v1] kfence: fix KASAN HW tags bypass via runtime sample_interval change

1 view
Skip to first unread message

Alexander Potapenko

unread,
May 7, 2026, 5:52:45 AM (13 days ago) May 7
to gli...@google.com, ak...@linux-foundation.org, linu...@kvack.org, linux-...@vger.kernel.org, kasa...@googlegroups.com, pi...@google.com, Marco Elver, Greg Thelen, Roman Gushchin
If a user writes a non-zero value to the sample_interval module parameter
at runtime, the missing KASAN HW tags check in the late init path allows
KFENCE to be enabled alongside KASAN HW tags, bypassing the boot
restriction.
This patch adds the missing check to param_set_sample_interval() to reject
the parameter change if KASAN HW tags are enabled.

Fixes: 09833d99db36 ("mm/kfence: disable KFENCE upon KASAN HW tags enablement")
Cc: Marco Elver <el...@google.com>
Cc: Greg Thelen <gth...@google.com>
Cc: Roman Gushchin <roman.g...@linux.dev>
Signed-off-by: Alexander Potapenko <gli...@google.com>
---
mm/kfence/core.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 655dc5ce3240..ee6ae01de5ae 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -77,6 +77,11 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
WRITE_ONCE(kfence_enabled, false);
}

+ if (num && kasan_hw_tags_enabled()) {
+ pr_info("disabled as KASAN HW tags are enabled\n");
+ return -EINVAL;
+ }
+
*((unsigned long *)kp->arg) = num;

if (num && !READ_ONCE(kfence_enabled) && system_state != SYSTEM_BOOTING)
--
2.54.0.545.g6539524ca2-goog

Reply all
Reply to author
Forward
0 new messages