Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jul 2026 19:47:02 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 2e259c209f69 - main - kern_pdwait(): print the process pointer through pd
Message-ID:  <6a690736.460e2.28a1b3b7@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=2e259c209f6912bc99e18bbfb55dd10554b3b11d

commit 2e259c209f6912bc99e18bbfb55dd10554b3b11d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-07-27 23:37:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-07-28 19:45:52 +0000

    kern_pdwait(): print the process pointer through pd
    
    to avoid using uninitialized value in the KASSERT() statement on the first
    iteration.
    
    Also, do the assert under the proctree_lock, which is not critical but
    satisfies the invariants.
    
    Noted and reviewed by:  markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D58505
---
 sys/kern/kern_exit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index c43bd69554e7..ebe4aa40c128 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -1572,12 +1572,12 @@ kern_pdwait(struct thread *td, int fd, int *status,
 		goto exit_unlocked;
 
 	for (;;) {
+		sx_xlock(&proctree_lock);
 		/* We own a reference on the procdesc file. */
 		KASSERT(pd->pd_fpcount > 0,
 		    ("closed proc %p procdesc %p pd flags %#x",
-		    p, pd, pd->pd_flags));
+		    pd->pd_proc, pd, pd->pd_flags));
 
-		sx_xlock(&proctree_lock);
 		p = pd->pd_proc;
 		if (p == NULL) {
 			error = ESRCH;


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a690736.460e2.28a1b3b7>