fork_norfproc(): unlock p1 before retrying

Reported and reviewed by:	markj
Tested by:	pho
Syzkaller:	647212368c3f32c6f13f
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36207
This commit is contained in:
Konstantin Belousov 2022-08-10 20:03:31 +03:00
parent 0a4f2ac3b7
commit 5e9bba94bd

View File

@ -323,13 +323,11 @@ fork_norfproc(struct thread *td, int flags)
if ((p1->p_flag & (P_HADTHREADS | P_SYSTEM)) == P_HADTHREADS &&
((flags & (RFCFDG | RFFDG)) != 0 || (flags & RFMEM) == 0)) {
PROC_LOCK(p1);
while (p1->p_singlethr > 0) {
if (p1->p_singlethr > 0) {
error = msleep(&p1->p_singlethr, &p1->p_mtx,
PWAIT | PCATCH, "rfork1t", 0);
if (error != 0) {
PROC_UNLOCK(p1);
PWAIT | PCATCH | PDROP, "rfork1t", 0);
if (error != 0)
return (ERESTART);
}
goto again;
}
if (thread_single(p1, SINGLE_BOUNDARY)) {