summaryrefslogtreecommitdiff
path: root/sys/kern/kern_proc.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-10-22 11:54:06 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-10-22 11:54:06 +0000
commit5b35c9fbe68e11041130d9e75b8de64c8dd7b10d (patch)
tree90104d228335b8346513333c0d4be3ab8173283b /sys/kern/kern_proc.c
parent591ef9867a45fb65abc32e58212a898514120d2d (diff)
Protect the ps_pgrp pointer by either the KERNEL_LOCK or the ps_mtx.
This should be enough to be on the safe side when unlocking ptsignal where a pr->ps_pgrp->pg_jobc == 0 check happens. OK mpi@ kettenis@
Diffstat (limited to 'sys/kern/kern_proc.c')
-rw-r--r--sys/kern/kern_proc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index f061b06cffe..7abbab5fd48 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.100 2024/10/15 13:49:26 claudio Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.101 2024/10/22 11:54:04 claudio Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -319,7 +319,9 @@ enterthispgrp(struct process *pr, struct pgrp *pgrp)
fixjobc(pr, savepgrp, 0);
LIST_REMOVE(pr, ps_pglist);
+ mtx_enter(&pr->ps_mtx);
pr->ps_pgrp = pgrp;
+ mtx_leave(&pr->ps_mtx);
LIST_INSERT_HEAD(&pgrp->pg_members, pr, ps_pglist);
if (LIST_EMPTY(&savepgrp->pg_members))
pgdelete(savepgrp);
@@ -337,7 +339,9 @@ leavepgrp(struct process *pr)
LIST_REMOVE(pr, ps_pglist);
if (LIST_EMPTY(&pr->ps_pgrp->pg_members))
pgdelete(pr->ps_pgrp);
+ mtx_enter(&pr->ps_mtx);
pr->ps_pgrp = NULL;
+ mtx_leave(&pr->ps_mtx);
}
/*