Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Oct 2023 13:38:28 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 53f62d1c9a9c - stable/14 - witness: Unconditionally initialize out-params for witness_save()
Message-ID:  <202310241338.39ODcSFn089529@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=53f62d1c9a9cce1ba1e04fe68c5ae3e5a9a2e656

commit 53f62d1c9a9cce1ba1e04fe68c5ae3e5a9a2e656
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-10-16 17:23:40 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-10-24 13:20:55 +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
    
    (cherry picked from commit 7123222220aa563dc16bf1989d335722e4ff57a6)
---
 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310241338.39ODcSFn089529>