Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 May 2021 13:49:31 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: 44d26e9e781f - stable/13 - smp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry()
Message-ID:  <202105101349.14ADnV1C026451@gitrepo.freebsd.org>

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

URL: https://cgit.FreeBSD.org/src/commit/?id=44d26e9e781fdf47fe0e1e6c987d519a751b14fa

commit 44d26e9e781fdf47fe0e1e6c987d519a751b14fa
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-05-03 16:43:00 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-05-10 13:35:53 +0000

    smp: Initialize arg->cpus sooner in smp_rendezvous_cpus_retry()
    
    Otherwise, if !smp_started is true, then smp_rendezvous_cpus_done() will
    harmlessly perform an atomic RMW on an uninitialized variable.
    
    Reported by:    KMSAN
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit cdfcfc607acc10c8b1b2b6a427c9e1ed7e94ebb3)
---
 sys/kern/subr_smp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c
index 093622d8f6aa..d4f8aac9e751 100644
--- a/sys/kern/subr_smp.c
+++ b/sys/kern/subr_smp.c
@@ -895,6 +895,8 @@ smp_rendezvous_cpus_retry(cpuset_t map,
 {
 	int cpu;
 
+	CPU_COPY(&map, &arg->cpus);
+
 	/*
 	 * Only one CPU to execute on.
 	 */
@@ -914,7 +916,6 @@ smp_rendezvous_cpus_retry(cpuset_t map,
 	 * Execute an action on all specified CPUs while retrying until they
 	 * all acknowledge completion.
 	 */
-	CPU_COPY(&map, &arg->cpus);
 	for (;;) {
 		smp_rendezvous_cpus(
 		    arg->cpus,



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