aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-10-16 17:23:40 +0000
committerMark Johnston <markj@FreeBSD.org>2023-10-24 13:20:55 +0000
commit53f62d1c9a9cce1ba1e04fe68c5ae3e5a9a2e656 (patch)
tree44170876d8dc6368025ed88d76d512c53d30ebbc
parent501e1152d2a047f8ff8fba6e6efbd2d5e9872738 (diff)
downloadsrc-53f62d1c9a9cce1ba1e04fe68c5ae3e5a9a2e656.tar.gz
src-53f62d1c9a9cce1ba1e04fe68c5ae3e5a9a2e656.zip
witness: Unconditionally initialize out-params for witness_save()
As of LLVM 16, the -fsanitize-memory-param-retval option is set to true by default, meaning that MSan will eagerly report uninitialized function parameters and return values, even if they are not used. A witness_save()/witness_restore() call pair fails this test since witness_save() may return before saving file and line number information. Modify witness_save() to initialize the out-params unconditionally; this appears to be the only instance of the problem triggered when booting to a login prompt, so let's just address it directly. Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. MFC after: 1 week (cherry picked from commit 7123222220aa563dc16bf1989d335722e4ff57a6)
-rw-r--r--sys/kern/subr_witness.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index d4ab085197f4..5b9f8afd9565 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -2362,6 +2362,10 @@ witness_save(struct lock_object *lock, const char **filep, int *linep)
struct lock_instance *instance;
struct lock_class *class;
+ /* Initialize for KMSAN's benefit. */
+ *filep = NULL;
+ *linep = 0;
+
/*
* This function is used independently in locking code to deal with
* Giant, SCHEDULER_STOPPED() check can be removed here after Giant