diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-01-15 15:47:38 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-01-15 15:47:38 +0000 |
commit | cea5479f9f05a949289015fe5b468b9ce0cc62a1 (patch) | |
tree | 37eca19b5080b89dbc3685f827b0348d7bd030fe /sys/kern/kern_exit.c | |
parent | 576454b99fe7638b52cdfea5d10bf7f6bfef2a1f (diff) |
Introduce priterator(), the `ps_list' iterator. Some of `allprocess'
list walkthroughs have context switch within, so make exit1() wait
until the last reference released.
Reported-by: syzbot+0e9dda76c42c82c626d7@syzkaller.appspotmail.com
ok bluhm claudio
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r-- | sys/kern/kern_exit.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index ce6aea2aa1b..06aabdc0775 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.217 2023/09/29 12:47:34 claudio Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.218 2024/01/15 15:47:37 mvs Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -165,6 +165,8 @@ exit1(struct proc *p, int xexit, int xsig, int flags) /* main thread gotta wait because it has the pid, et al */ while (pr->ps_threadcnt > 1) tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP); + LIST_REMOVE(pr, ps_list); + refcnt_finalize(&pr->ps_refcnt, "psdtor"); } rup = pr->ps_ru; @@ -252,7 +254,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags) if ((p->p_flag & P_THREAD) == 0) { LIST_REMOVE(pr, ps_hash); - LIST_REMOVE(pr, ps_list); if ((pr->ps_flags & PS_NOZOMBIE) == 0) LIST_INSERT_HEAD(&zombprocess, pr, ps_list); |