Fix LOR that occurs because proctree_lock was acquired while holding

emuldata lock by moving the code upwards outside the emul_lock coverage.

Submitted by: rdivacky
This commit is contained in:
Konstantin Belousov 2007-02-01 13:27:52 +00:00
parent 84fbdf86b3
commit a9ccaccfc3
2 changed files with 16 additions and 16 deletions

View File

@ -591,6 +591,14 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
error = fork1(td, ff, 0, &p2);
if (error)
return (error);
if (args->flags & (CLONE_PARENT|CLONE_THREAD)) {
sx_xlock(&proctree_lock);
PROC_LOCK(p2);
proc_reparent(p2, td->td_proc->p_pptr);
PROC_UNLOCK(p2);
sx_xunlock(&proctree_lock);
}
/* create the emuldata */
error = linux_proc_init(td, p2->p_pid, args->flags);
@ -610,14 +618,6 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
}
}
if (args->flags & (CLONE_PARENT|CLONE_THREAD)) {
sx_xlock(&proctree_lock);
PROC_LOCK(p2);
proc_reparent(p2, td->td_proc->p_pptr);
PROC_UNLOCK(p2);
sx_xunlock(&proctree_lock);
}
if (args->flags & CLONE_THREAD) {
/* XXX: linux mangles pgrp and pptr somehow
* I think it might be this but I am not sure.

View File

@ -438,6 +438,14 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
error = fork1(td, ff, 0, &p2);
if (error)
return (error);
if (args->flags & (CLONE_PARENT|CLONE_THREAD)) {
sx_xlock(&proctree_lock);
PROC_LOCK(p2);
proc_reparent(p2, td->td_proc->p_pptr);
PROC_UNLOCK(p2);
sx_xunlock(&proctree_lock);
}
/* create the emuldata */
error = linux_proc_init(td, p2->p_pid, args->flags);
@ -457,14 +465,6 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
}
}
if (args->flags & (CLONE_PARENT|CLONE_THREAD)) {
sx_xlock(&proctree_lock);
PROC_LOCK(p2);
proc_reparent(p2, td->td_proc->p_pptr);
PROC_UNLOCK(p2);
sx_xunlock(&proctree_lock);
}
if (args->flags & CLONE_THREAD) {
/* XXX: linux mangles pgrp and pptr somehow
* I think it might be this but I am not sure.