mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-11 04:42:16 +01:00
Finish fixing up Alpha to work with an MP safe ptrace():
- ptrace_single_step() is no longer called with the proc lock held, so don't try to unlock it and then relock it. - Push Giant down into proc_rwmem() instead of forcing all the consumers (including Alpha breakpoint support) to explicitly wrap calls to proc_rwmem() with Giant. Tested by: kensmith
This commit is contained in:
parent
30a416556d
commit
03d6afada4
@ -1914,10 +1914,9 @@ ptrace_single_step(struct thread *td)
|
||||
if (td->td_md.md_flags & (MDTD_STEP1|MDTD_STEP2))
|
||||
panic("ptrace_single_step: step breakpoints not removed");
|
||||
|
||||
PROC_UNLOCK(td->td_proc);
|
||||
error = ptrace_read_int(td, pc, &ins.bits);
|
||||
if (error)
|
||||
goto err;
|
||||
return (error);
|
||||
|
||||
switch (ins.branch_format.opcode) {
|
||||
|
||||
@ -1957,20 +1956,18 @@ ptrace_single_step(struct thread *td)
|
||||
td->td_md.md_sstep[0].addr = addr[0];
|
||||
error = ptrace_set_bpt(td, &td->td_md.md_sstep[0]);
|
||||
if (error)
|
||||
goto err;
|
||||
return (error);
|
||||
if (count == 2) {
|
||||
td->td_md.md_sstep[1].addr = addr[1];
|
||||
error = ptrace_set_bpt(td, &td->td_md.md_sstep[1]);
|
||||
if (error) {
|
||||
ptrace_clear_bpt(td, &td->td_md.md_sstep[0]);
|
||||
goto err;
|
||||
return (error);
|
||||
}
|
||||
td->td_md.md_flags |= MDTD_STEP2;
|
||||
} else
|
||||
td->td_md.md_flags |= MDTD_STEP1;
|
||||
|
||||
err:
|
||||
PROC_LOCK(td->td_proc);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -154,18 +154,21 @@ proc_rwmem(struct proc *p, struct uio *uio)
|
||||
vm_prot_t reqprot;
|
||||
int error, writing;
|
||||
|
||||
GIANT_REQUIRED;
|
||||
|
||||
mtx_lock(&Giant);
|
||||
/*
|
||||
* if the vmspace is in the midst of being deallocated or the
|
||||
* process is exiting, don't try to grab anything. The page table
|
||||
* usage in that process can be messed up.
|
||||
*/
|
||||
vm = p->p_vmspace;
|
||||
if ((p->p_flag & P_WEXIT))
|
||||
if ((p->p_flag & P_WEXIT)) {
|
||||
mtx_unlock(&Giant);
|
||||
return (EFAULT);
|
||||
if (vm->vm_refcnt < 1)
|
||||
}
|
||||
if (vm->vm_refcnt < 1) {
|
||||
mtx_unlock(&Giant);
|
||||
return (EFAULT);
|
||||
}
|
||||
++vm->vm_refcnt;
|
||||
/*
|
||||
* The map we want...
|
||||
@ -274,6 +277,7 @@ proc_rwmem(struct proc *p, struct uio *uio)
|
||||
} while (error == 0 && uio->uio_resid > 0);
|
||||
|
||||
vmspace_free(vm);
|
||||
mtx_unlock(&Giant);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -602,9 +606,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
uio.uio_segflg = UIO_SYSSPACE; /* i.e.: the uap */
|
||||
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
||||
uio.uio_td = td;
|
||||
mtx_lock(&Giant);
|
||||
error = proc_rwmem(p, &uio);
|
||||
mtx_unlock(&Giant);
|
||||
if (uio.uio_resid != 0) {
|
||||
/*
|
||||
* XXX proc_rwmem() doesn't currently return ENOSPC,
|
||||
@ -645,9 +647,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
default:
|
||||
return (EINVAL);
|
||||
}
|
||||
mtx_lock(&Giant);
|
||||
error = proc_rwmem(p, &uio);
|
||||
mtx_unlock(&Giant);
|
||||
piod->piod_len -= uio.uio_resid;
|
||||
return (error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user