aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenlei Huang <zlei@FreeBSD.org>2023-10-12 10:14:49 +0000
committerZhenlei Huang <zlei@FreeBSD.org>2023-10-12 10:14:49 +0000
commit1d2b743784f7527a6840fe35ddb7e34cd41bc17a (patch)
treebd07d4c0739a72881b0f9df8fe3340f6e978e235
parentdb5d0bc868be669ed6588ebeccf8c02e76aabc41 (diff)
downloadsrc-1d2b743784f7527a6840fe35ddb7e34cd41bc17a.tar.gz
src-1d2b743784f7527a6840fe35ddb7e34cd41bc17a.zip
kmsan: Add corresponding sysctl knob for loader tunable
The loader tunable 'debug.kmsan.disabled' does not have corresponding sysctl MIB entry. Add it so that it can be retrieved, and `sysctl -T` will also report it correctly. Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42138
-rw-r--r--sys/kern/subr_msan.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c
index 57caeb454b42..54948370a14a 100644
--- a/sys/kern/subr_msan.c
+++ b/sys/kern/subr_msan.c
@@ -108,15 +108,13 @@ static uint8_t msan_dummy_shad[PAGE_SIZE] __aligned(PAGE_SIZE);
static uint8_t msan_dummy_write_shad[PAGE_SIZE] __aligned(PAGE_SIZE);
static uint8_t msan_dummy_orig[PAGE_SIZE] __aligned(PAGE_SIZE);
static msan_td_t msan_thread0;
-static bool kmsan_enabled __read_mostly;
-
static bool kmsan_reporting = false;
/*
* Avoid clobbering any thread-local state before we panic.
*/
#define kmsan_panic(f, ...) do { \
- kmsan_enabled = false; \
+ kmsan_disabled = true; \
panic(f, __VA_ARGS__); \
} while (0)
@@ -142,6 +140,11 @@ SYSCTL_BOOL(_debug_kmsan, OID_AUTO, panic_on_violation, CTLFLAG_RWTUN,
&panic_on_violation, 0,
"Panic if an invalid access is detected");
+static bool kmsan_disabled __read_mostly = true;
+#define kmsan_enabled (!kmsan_disabled)
+SYSCTL_BOOL(_debug_kmsan, OID_AUTO, disabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
+ &kmsan_disabled, 0, "KMSAN is disabled");
+
static MALLOC_DEFINE(M_KMSAN, "kmsan", "Kernel memory sanitizer");
/* -------------------------------------------------------------------------- */
@@ -599,7 +602,7 @@ kmsan_init(void)
thread0.td_kmsan = &msan_thread0;
/* Now officially enabled. */
- kmsan_enabled = true;
+ kmsan_disabled = false;
}
/* -------------------------------------------------------------------------- */