git: 7123222220aa - main - witness: Unconditionally initialize out-params for witness_save()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Oct 2023 13:37:02 UTC
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=7123222220aa563dc16bf1989d335722e4ff57a6 commit 7123222220aa563dc16bf1989d335722e4ff57a6 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2023-10-16 17:23:40 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2023-10-17 13:05:45 +0000 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 --- sys/kern/subr_witness.c | 4 ++++ 1 file changed, 4 insertions(+) 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