git: 831531a82e0f - main - prison_proc_iterate(): make it work for prison0

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 06 Dec 2024 21:42:39 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=831531a82e0f1d1d7b97e50c0587639322ed8d2e

commit 831531a82e0f1d1d7b97e50c0587639322ed8d2e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-12-06 17:01:00 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-12-06 21:42:26 +0000

    prison_proc_iterate(): make it work for prison0
    
    Do not exclude processes owned by host/prison0 if there are jails
    configured.
    
    PR:     283163
    Reviewed by:    jamie, markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D47943
---
 sys/kern/kern_jail.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 38aea998d196..80503570b776 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -3085,8 +3085,7 @@ prison_proc_iterate(struct prison *pr, void (*cb)(struct proc *, void *),
 	FOREACH_PROC_IN_SYSTEM(p) {
 		PROC_LOCK(p);
 		if (p->p_state != PRS_NEW && p->p_ucred != NULL) {
-			for (ppr = p->p_ucred->cr_prison;
-			    ppr != &prison0;
+			for (ppr = p->p_ucred->cr_prison; ppr != NULL;
 			    ppr = ppr->pr_parent) {
 				if (ppr == pr) {
 					cb(p, cbarg);