Some callers of proc_reparent() already have the parent process locked.
Detect the situation and avoid process lock recursion. Reported by: Fabian Keil <freebsd-listen fabiankeil de>
This commit is contained in:
parent
a827fe1fdf
commit
2cfd5d3c91
@ -903,15 +903,19 @@ kern_wait(struct thread *td, pid_t pid, int *status, int options,
|
||||
void
|
||||
proc_reparent(struct proc *child, struct proc *parent)
|
||||
{
|
||||
int locked;
|
||||
|
||||
sx_assert(&proctree_lock, SX_XLOCKED);
|
||||
PROC_LOCK_ASSERT(child, MA_OWNED);
|
||||
if (child->p_pptr == parent)
|
||||
return;
|
||||
|
||||
PROC_LOCK(parent);
|
||||
locked = PROC_LOCKED(parent);
|
||||
if (!locked)
|
||||
PROC_LOCK(parent);
|
||||
racct_add_force(parent, RACCT_NPROC, 1);
|
||||
PROC_UNLOCK(parent);
|
||||
if (!locked)
|
||||
PROC_UNLOCK(parent);
|
||||
PROC_LOCK(child->p_pptr);
|
||||
racct_sub(child->p_pptr, RACCT_NPROC, 1);
|
||||
sigqueue_take(child->p_ksi);
|
||||
|
Loading…
Reference in New Issue
Block a user