diff options
author | John Baldwin <jhb@FreeBSD.org> | 2006-02-22 18:57:50 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2006-02-22 18:57:50 +0000 |
commit | 06ad42b2f7280372512d6a36361c33c49f40b960 (patch) | |
tree | 51c4862ad08a234b42fff5687f7a934be133894b /sys/ia64 | |
parent | 57fb5e60974fbb2770aa12b4a72114660228c236 (diff) | |
download | src-06ad42b2f7280372512d6a36361c33c49f40b960.tar.gz src-06ad42b2f7280372512d6a36361c33c49f40b960.zip |
Close some races between procfs/ptrace and exit(2):
- Reorder the events in exit(2) slightly so that we trigger the S_EXIT
stop event earlier. After we have signalled that, we set P_WEXIT and
then wait for any processes with a hold on the vmspace via PHOLD to
release it. PHOLD now KASSERT()'s that P_WEXIT is clear when it is
invoked, and PRELE now does a wakeup if P_WEXIT is set and p_lock drops
to zero.
- Change proc_rwmem() to require that the processing read from has its
vmspace held via PHOLD by the caller and get rid of all the junk to
screw around with the vmspace reference count as we no longer need it.
- In ptrace() and pseudofs(), treat a process with P_WEXIT set as if it
doesn't exist.
- Only do one PHOLD in kern_ptrace() now, and do it earlier so it covers
FIX_SSTEP() (since on alpha at least this can end up calling proc_rwmem()
to clear an earlier single-step simualted via a breakpoint). We only
do one to avoid races. Also, by making the EINVAL error for unknown
requests be part of the default: case in the switch, the various
switch cases can now just break out to return which removes a _lot_ of
duplicated PRELE and proc unlocks, etc. Also, it fixes at least one bug
where a LWP ptrace command could return EINVAL with the proc lock still
held.
- Changed the locking for ptrace_single_step(), ptrace_set_pc(), and
ptrace_clear_single_step() to always be called with the proc lock
held (it was a mixed bag previously). Alpha and arm have to drop
the lock while the mess around with breakpoints, but other archs
avoid extra lock release/acquires in ptrace(). I did have to fix a
couple of other consumers in kern_kse and a few other places to
hold the proc lock and PHOLD.
Tested by: ps (1 mostly, but some bits of 2-4 as well)
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=155922
Diffstat (limited to 'sys/ia64')
-rw-r--r-- | sys/ia64/ia64/machdep.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index e9521bed82e4..22d5e7252d4d 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -1097,6 +1097,7 @@ ia64_flush_dirty(struct thread *td, struct _special *r) r->rnat = (bspst > kstk && (bspst & 0x1ffL) < (kstk & 0x1ffL)) ? *(uint64_t*)(kstk | 0x1f8L) : rnat; } else { + PHOLD(td->td_proc); iov.iov_base = (void*)(uintptr_t)kstk; iov.iov_len = r->ndirty; uio.uio_iov = &iov; @@ -1114,6 +1115,7 @@ ia64_flush_dirty(struct thread *td, struct _special *r) */ if (uio.uio_resid != 0 && error == 0) error = ENOSPC; + PRELE(td->td_proc); } r->bspstore += r->ndirty; |