From: Alexander Potapenko <glider@google.com>
To: glider@google.com
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com,
pimyn@google.com, Marco Elver <elver@google.com>,
Greg Thelen <gthelen@google.com>,
Roman Gushchin <roman.gushchin@linux.dev>
Subject: [PATCH v1] kfence: fix KASAN HW tags bypass via runtime sample_interval change
Date: Thu, 7 May 2026 11:52:37 +0200 [thread overview]
Message-ID: <20260507095237.741017-1-glider@google.com> (raw)
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 <elver@google.com>
Cc: Greg Thelen <gthelen@google.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Alexander Potapenko <glider@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 other threads:[~2026-05-07 9:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260507095237.741017-1-glider@google.com \
--to=glider@google.com \
--cc=akpm@linux-foundation.org \
--cc=elver@google.com \
--cc=gthelen@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pimyn@google.com \
--cc=roman.gushchin@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox