diff options
author | John Baldwin <jhb@FreeBSD.org> | 2004-03-15 18:48:28 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2004-03-15 18:48:28 +0000 |
commit | 8ac61436e6793deeba249d8e2b8332d60c83470f (patch) | |
tree | 8eba7733b3a1f60380c2220587bc77c938f2c537 /sys | |
parent | d2b1b4f3c57dde2d2206df5b799a7409237ed91d (diff) | |
download | src-8ac61436e6793deeba249d8e2b8332d60c83470f.tar.gz src-8ac61436e6793deeba249d8e2b8332d60c83470f.zip |
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
Notes
Notes:
svn path=/head/; revision=127034
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/sys_process.c | 17 | ||||
-rw-r--r-- | sys/kern/syscalls.master | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 7a0c02ea01eb..636d10bdba06 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -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); diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index f23f05607a37..aa9c9696bba9 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -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, \ |