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
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=166395
2 changed files with 16 additions and 16 deletions

View file

@ -592,6 +592,14 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
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);
/* reference it - no need to check this */
@ -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

@ -439,6 +439,14 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
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);
/* reference it - no need to check this */
@ -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.