Drop the proc lock around calls to the MD functions ptrace_single_step(),
ptrace_set_pc(), and cpu_ptrace() so that those functions are free to acquire Giant, sleep, etc. We already do a PHOLD/PRELE around them so that it is safe to sleep inside of these routines if necessary. This allows ptrace() to be marked MP safe again as it no longer triggers lock order reversals on Alpha. Tested by: wilko
This commit is contained in:
parent
2fe413a41a
commit
d8445e0c8d
@ -522,11 +522,13 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
|
||||
switch (req) {
|
||||
case PT_STEP:
|
||||
PROC_UNLOCK(p);
|
||||
error = ptrace_single_step(td2);
|
||||
if (error) {
|
||||
_PRELE(p);
|
||||
goto fail;
|
||||
PRELE(p);
|
||||
goto fail_noproc;
|
||||
}
|
||||
PROC_LOCK(p);
|
||||
break;
|
||||
case PT_TO_SCE:
|
||||
p->p_stops |= S_PT_SCE;
|
||||
@ -540,11 +542,13 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
}
|
||||
|
||||
if (addr != (void *)1) {
|
||||
PROC_UNLOCK(p);
|
||||
error = ptrace_set_pc(td2, (u_long)(uintfptr_t)addr);
|
||||
if (error) {
|
||||
_PRELE(p);
|
||||
goto fail;
|
||||
PRELE(p);
|
||||
goto fail_noproc;
|
||||
}
|
||||
PROC_LOCK(p);
|
||||
}
|
||||
_PRELE(p);
|
||||
|
||||
@ -705,9 +709,9 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
#ifdef __HAVE_PTRACE_MACHDEP
|
||||
if (req >= PT_FIRSTMACH) {
|
||||
_PHOLD(p);
|
||||
error = cpu_ptrace(td2, req, addr, data);
|
||||
_PRELE(p);
|
||||
PROC_UNLOCK(p);
|
||||
error = cpu_ptrace(td2, req, addr, data);
|
||||
PRELE(p);
|
||||
return (error);
|
||||
}
|
||||
#endif
|
||||
@ -719,6 +723,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
|
||||
fail:
|
||||
PROC_UNLOCK(p);
|
||||
fail_noproc:
|
||||
if (proctree_locked)
|
||||
sx_xunlock(&proctree_lock);
|
||||
return (error);
|
||||
|
@ -76,7 +76,7 @@
|
||||
23 MSTD { int setuid(uid_t uid); }
|
||||
24 MSTD { uid_t getuid(void); }
|
||||
25 MSTD { uid_t geteuid(void); }
|
||||
26 STD { int ptrace(int req, pid_t pid, caddr_t addr, int data); }
|
||||
26 MSTD { int ptrace(int req, pid_t pid, caddr_t addr, int data); }
|
||||
27 MSTD { int recvmsg(int s, struct msghdr *msg, int flags); }
|
||||
28 MSTD { int sendmsg(int s, struct msghdr *msg, int flags); }
|
||||
29 MSTD { int recvfrom(int s, caddr_t buf, size_t len, int flags, \
|
||||
|
Loading…
x
Reference in New Issue
Block a user