Zap 'ptrace(PT_READ_U, ...)' and 'ptrace(PT_WRITE_U, ...)' since they
are a really nasty interface that should have been killed long ago when 'ptrace(PT_[SG]ETREGS' etc came along. The entity that they operate on (struct user) will not be around much longer since it is part-per-process and part-per-thread in a post-KSE world. gdb does not actually use this except for the obscure 'info udot' command which does a hexdump of as much of the child's 'struct user' as it can get. It carries its own #defines so it doesn't break compiles.
This commit is contained in:
parent
73466163c0
commit
231d73a816
@ -1851,62 +1851,6 @@ ptrace_single_step(struct proc *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ptrace_read_u_check(p, addr, len)
|
||||
struct proc *p;
|
||||
vm_offset_t addr;
|
||||
size_t len;
|
||||
{
|
||||
vm_offset_t gap;
|
||||
|
||||
if ((vm_offset_t) (addr + len) < addr)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <= sizeof(struct user))
|
||||
return 0;
|
||||
|
||||
gap = (char *) p->p_frame - (char *) p->p_addr;
|
||||
|
||||
if ((vm_offset_t) addr < gap)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <=
|
||||
(vm_offset_t) (gap + sizeof(struct trapframe)))
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_write_u(struct proc *p, vm_offset_t off, long data)
|
||||
{
|
||||
vm_offset_t min;
|
||||
#if 0
|
||||
struct trapframe frame_copy;
|
||||
struct trapframe *tp;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Privileged kernel state is scattered all over the user area.
|
||||
* Only allow write access to parts of regs and to fpregs.
|
||||
*/
|
||||
min = (char *)p->p_frame - (char *)p->p_addr;
|
||||
if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
|
||||
#if 0
|
||||
tp = p->p_frame;
|
||||
frame_copy = *tp;
|
||||
*(int *)((char *)&frame_copy + (off - min)) = data;
|
||||
if (!EFLAGS_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(frame_copy.tf_cs))
|
||||
return (EINVAL);
|
||||
#endif
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_fp);
|
||||
if (off >= min && off <= min + sizeof(struct fpreg) - sizeof(int)) {
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
alpha_pa_access(vm_offset_t pa)
|
||||
{
|
||||
|
@ -47,10 +47,4 @@
|
||||
|
||||
#define FIX_SSTEP(p) ptrace_clear_single_step(p)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int ptrace_clear_single_step __P((struct proc *p));
|
||||
int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -2054,60 +2054,6 @@ ptrace_single_step(p)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ptrace_read_u_check(p, addr, len)
|
||||
struct proc *p;
|
||||
vm_offset_t addr;
|
||||
size_t len;
|
||||
{
|
||||
vm_offset_t gap;
|
||||
|
||||
if ((vm_offset_t) (addr + len) < addr)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <= sizeof(struct user))
|
||||
return 0;
|
||||
|
||||
gap = (char *) p->p_frame - (char *) p->p_addr;
|
||||
|
||||
if ((vm_offset_t) addr < gap)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <=
|
||||
(vm_offset_t) (gap + sizeof(struct trapframe)))
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
int ptrace_write_u(p, off, data)
|
||||
struct proc *p;
|
||||
vm_offset_t off;
|
||||
long data;
|
||||
{
|
||||
struct trapframe frame_copy;
|
||||
vm_offset_t min;
|
||||
struct trapframe *tp;
|
||||
|
||||
/*
|
||||
* Privileged kernel state is scattered all over the user area.
|
||||
* Only allow write access to parts of regs and to fpregs.
|
||||
*/
|
||||
min = (char *)p->p_frame - (char *)p->p_addr;
|
||||
if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
|
||||
tp = p->p_frame;
|
||||
frame_copy = *tp;
|
||||
*(int *)((char *)&frame_copy + (off - min)) = data;
|
||||
if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(frame_copy.tf_cs))
|
||||
return (EINVAL);
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_save);
|
||||
if (off >= min && off <= min + sizeof(union savefpu) - sizeof(int)) {
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
fill_regs(p, regs)
|
||||
struct proc *p;
|
||||
|
@ -47,9 +47,4 @@
|
||||
#define PT_GETDBREGS (PT_FIRSTMACH + 5)
|
||||
#define PT_SETDBREGS (PT_FIRSTMACH + 6)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -2054,60 +2054,6 @@ ptrace_single_step(p)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ptrace_read_u_check(p, addr, len)
|
||||
struct proc *p;
|
||||
vm_offset_t addr;
|
||||
size_t len;
|
||||
{
|
||||
vm_offset_t gap;
|
||||
|
||||
if ((vm_offset_t) (addr + len) < addr)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <= sizeof(struct user))
|
||||
return 0;
|
||||
|
||||
gap = (char *) p->p_frame - (char *) p->p_addr;
|
||||
|
||||
if ((vm_offset_t) addr < gap)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <=
|
||||
(vm_offset_t) (gap + sizeof(struct trapframe)))
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
int ptrace_write_u(p, off, data)
|
||||
struct proc *p;
|
||||
vm_offset_t off;
|
||||
long data;
|
||||
{
|
||||
struct trapframe frame_copy;
|
||||
vm_offset_t min;
|
||||
struct trapframe *tp;
|
||||
|
||||
/*
|
||||
* Privileged kernel state is scattered all over the user area.
|
||||
* Only allow write access to parts of regs and to fpregs.
|
||||
*/
|
||||
min = (char *)p->p_frame - (char *)p->p_addr;
|
||||
if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
|
||||
tp = p->p_frame;
|
||||
frame_copy = *tp;
|
||||
*(int *)((char *)&frame_copy + (off - min)) = data;
|
||||
if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(frame_copy.tf_cs))
|
||||
return (EINVAL);
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_save);
|
||||
if (off >= min && off <= min + sizeof(union savefpu) - sizeof(int)) {
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
fill_regs(p, regs)
|
||||
struct proc *p;
|
||||
|
@ -47,9 +47,4 @@
|
||||
#define PT_GETDBREGS (PT_FIRSTMACH + 5)
|
||||
#define PT_SETDBREGS (PT_FIRSTMACH + 6)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1084,59 +1084,6 @@ ptrace_single_step(struct proc *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ptrace_read_u_check(struct proc *p, vm_offset_t addr, size_t len)
|
||||
{
|
||||
vm_offset_t gap;
|
||||
|
||||
if ((vm_offset_t) (addr + len) < addr)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <= sizeof(struct user))
|
||||
return 0;
|
||||
|
||||
gap = (char *) p->p_frame - (char *) p->p_addr;
|
||||
|
||||
if ((vm_offset_t) addr < gap)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <=
|
||||
(vm_offset_t) (gap + sizeof(struct trapframe)))
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_write_u(struct proc *p, vm_offset_t off, long data)
|
||||
{
|
||||
vm_offset_t min;
|
||||
#if 0
|
||||
struct trapframe frame_copy;
|
||||
struct trapframe *tp;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Privileged kernel state is scattered all over the user area.
|
||||
* Only allow write access to parts of regs and to fpregs.
|
||||
*/
|
||||
min = (char *)p->p_frame - (char *)p->p_addr;
|
||||
if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
|
||||
#if 0
|
||||
tp = p->p_frame;
|
||||
frame_copy = *tp;
|
||||
*(int *)((char *)&frame_copy + (off - min)) = data;
|
||||
if (!EFLAGS_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(frame_copy.tf_cs))
|
||||
return (EINVAL);
|
||||
#endif
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
min = offsetof(struct user, u_pcb);
|
||||
if (off >= min && off <= min + sizeof(struct pcb)) {
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
ia64_pa_access(vm_offset_t pa)
|
||||
{
|
||||
|
@ -45,9 +45,4 @@
|
||||
#define PT_GETFPREGS (PT_FIRSTMACH + 3)
|
||||
#define PT_SETFPREGS (PT_FIRSTMACH + 4)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -256,10 +256,8 @@ ptrace(curp, uap)
|
||||
|
||||
case PT_READ_I:
|
||||
case PT_READ_D:
|
||||
case PT_READ_U:
|
||||
case PT_WRITE_I:
|
||||
case PT_WRITE_D:
|
||||
case PT_WRITE_U:
|
||||
case PT_CONTINUE:
|
||||
case PT_KILL:
|
||||
case PT_STEP:
|
||||
@ -448,47 +446,6 @@ ptrace(curp, uap)
|
||||
}
|
||||
return (error);
|
||||
|
||||
case PT_READ_U:
|
||||
if ((uintptr_t)uap->addr > UPAGES * PAGE_SIZE - sizeof(int)) {
|
||||
return EFAULT;
|
||||
}
|
||||
if ((uintptr_t)uap->addr & (sizeof(int) - 1)) {
|
||||
return EFAULT;
|
||||
}
|
||||
if (ptrace_read_u_check(p,(vm_offset_t) uap->addr,
|
||||
sizeof(int))) {
|
||||
return EFAULT;
|
||||
}
|
||||
error = 0;
|
||||
PHOLD(p); /* user had damn well better be incore! */
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_sflag & PS_INMEM) {
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
fill_kinfo_proc (p, &p->p_addr->u_kproc);
|
||||
curp->p_retval[0] = *(int *)
|
||||
((uintptr_t)p->p_addr + (uintptr_t)uap->addr);
|
||||
} else {
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
curp->p_retval[0] = 0;
|
||||
error = EFAULT;
|
||||
}
|
||||
PRELE(p);
|
||||
return error;
|
||||
|
||||
case PT_WRITE_U:
|
||||
PHOLD(p); /* user had damn well better be incore! */
|
||||
mtx_lock_spin(&sched_lock);
|
||||
if (p->p_sflag & PS_INMEM) {
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
fill_kinfo_proc (p, &p->p_addr->u_kproc);
|
||||
error = ptrace_write_u(p, (vm_offset_t)uap->addr, uap->data);
|
||||
} else {
|
||||
mtx_unlock_spin(&sched_lock);
|
||||
error = EFAULT;
|
||||
}
|
||||
PRELE(p);
|
||||
return error;
|
||||
|
||||
case PT_KILL:
|
||||
uap->data = SIGKILL;
|
||||
goto sendsig; /* in PT_CONTINUE above */
|
||||
|
@ -2118,60 +2118,6 @@ ptrace_single_step(p)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ptrace_read_u_check(p, addr, len)
|
||||
struct proc *p;
|
||||
vm_offset_t addr;
|
||||
size_t len;
|
||||
{
|
||||
vm_offset_t gap;
|
||||
|
||||
if ((vm_offset_t) (addr + len) < addr)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <= sizeof(struct user))
|
||||
return 0;
|
||||
|
||||
gap = (char *) p->p_frame - (char *) p->p_addr;
|
||||
|
||||
if ((vm_offset_t) addr < gap)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <=
|
||||
(vm_offset_t) (gap + sizeof(struct trapframe)))
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
int ptrace_write_u(p, off, data)
|
||||
struct proc *p;
|
||||
vm_offset_t off;
|
||||
long data;
|
||||
{
|
||||
struct trapframe frame_copy;
|
||||
vm_offset_t min;
|
||||
struct trapframe *tp;
|
||||
|
||||
/*
|
||||
* Privileged kernel state is scattered all over the user area.
|
||||
* Only allow write access to parts of regs and to fpregs.
|
||||
*/
|
||||
min = (char *)p->p_frame - (char *)p->p_addr;
|
||||
if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
|
||||
tp = p->p_frame;
|
||||
frame_copy = *tp;
|
||||
*(int *)((char *)&frame_copy + (off - min)) = data;
|
||||
if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(frame_copy.tf_cs))
|
||||
return (EINVAL);
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_save);
|
||||
if (off >= min && off <= min + sizeof(union savefpu) - sizeof(int)) {
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
fill_regs(p, regs)
|
||||
struct proc *p;
|
||||
|
@ -2118,60 +2118,6 @@ ptrace_single_step(p)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ptrace_read_u_check(p, addr, len)
|
||||
struct proc *p;
|
||||
vm_offset_t addr;
|
||||
size_t len;
|
||||
{
|
||||
vm_offset_t gap;
|
||||
|
||||
if ((vm_offset_t) (addr + len) < addr)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <= sizeof(struct user))
|
||||
return 0;
|
||||
|
||||
gap = (char *) p->p_frame - (char *) p->p_addr;
|
||||
|
||||
if ((vm_offset_t) addr < gap)
|
||||
return EPERM;
|
||||
if ((vm_offset_t) (addr + len) <=
|
||||
(vm_offset_t) (gap + sizeof(struct trapframe)))
|
||||
return 0;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
int ptrace_write_u(p, off, data)
|
||||
struct proc *p;
|
||||
vm_offset_t off;
|
||||
long data;
|
||||
{
|
||||
struct trapframe frame_copy;
|
||||
vm_offset_t min;
|
||||
struct trapframe *tp;
|
||||
|
||||
/*
|
||||
* Privileged kernel state is scattered all over the user area.
|
||||
* Only allow write access to parts of regs and to fpregs.
|
||||
*/
|
||||
min = (char *)p->p_frame - (char *)p->p_addr;
|
||||
if (off >= min && off <= min + sizeof(struct trapframe) - sizeof(int)) {
|
||||
tp = p->p_frame;
|
||||
frame_copy = *tp;
|
||||
*(int *)((char *)&frame_copy + (off - min)) = data;
|
||||
if (!EFL_SECURE(frame_copy.tf_eflags, tp->tf_eflags) ||
|
||||
!CS_SECURE(frame_copy.tf_cs))
|
||||
return (EINVAL);
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
min = offsetof(struct user, u_pcb) + offsetof(struct pcb, pcb_save);
|
||||
if (off >= min && off <= min + sizeof(union savefpu) - sizeof(int)) {
|
||||
*(int*)((char *)p->p_addr + off) = data;
|
||||
return (0);
|
||||
}
|
||||
return (EFAULT);
|
||||
}
|
||||
|
||||
int
|
||||
fill_regs(p, regs)
|
||||
struct proc *p;
|
||||
|
@ -963,22 +963,6 @@ ptrace_single_step(struct proc *p)
|
||||
return (ENOSYS);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_write_u(struct proc *p, vm_offset_t off, long data)
|
||||
{
|
||||
|
||||
/* XXX: coming soon... */
|
||||
return (ENOSYS);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_read_u_check(struct proc *p, vm_offset_t addr, size_t len)
|
||||
{
|
||||
|
||||
/* XXX: coming soon... */
|
||||
return (ENOSYS);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_clear_single_step(struct proc *p)
|
||||
{
|
||||
|
@ -47,9 +47,4 @@
|
||||
#define PT_GETDBREGS (PT_FIRSTMACH + 5)
|
||||
#define PT_SETDBREGS (PT_FIRSTMACH + 6)
|
||||
|
||||
#ifdef _KERNEL
|
||||
int ptrace_read_u_check __P((struct proc *p, vm_offset_t off, size_t len));
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -963,22 +963,6 @@ ptrace_single_step(struct proc *p)
|
||||
return (ENOSYS);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_write_u(struct proc *p, vm_offset_t off, long data)
|
||||
{
|
||||
|
||||
/* XXX: coming soon... */
|
||||
return (ENOSYS);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_read_u_check(struct proc *p, vm_offset_t addr, size_t len)
|
||||
{
|
||||
|
||||
/* XXX: coming soon... */
|
||||
return (ENOSYS);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_clear_single_step(struct proc *p)
|
||||
{
|
||||
|
@ -29,6 +29,4 @@
|
||||
#ifndef _MACHINE_PTRACE_H_
|
||||
#define _MACHINE_PTRACE_H_
|
||||
|
||||
int ptrace_read_u_check(struct proc *p, vm_offset_t off, size_t len);
|
||||
|
||||
#endif /* !_MACHINE_PTRACE_H_ */
|
||||
|
@ -364,20 +364,6 @@ cpu_halt(void)
|
||||
TODO;
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_read_u_check(struct proc *p, vm_offset_t addr, size_t len)
|
||||
{
|
||||
TODO;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_write_u(struct proc *p, vm_offset_t off, long data)
|
||||
{
|
||||
TODO;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ptrace_set_pc(struct proc *p, u_long addr)
|
||||
{
|
||||
|
@ -40,10 +40,10 @@
|
||||
#define PT_TRACE_ME 0 /* child declares it's being traced */
|
||||
#define PT_READ_I 1 /* read word in child's I space */
|
||||
#define PT_READ_D 2 /* read word in child's D space */
|
||||
#define PT_READ_U 3 /* read word in child's user structure */
|
||||
/* was PT_READ_U 3 * read word in child's user structure */
|
||||
#define PT_WRITE_I 4 /* write word in child's I space */
|
||||
#define PT_WRITE_D 5 /* write word in child's D space */
|
||||
#define PT_WRITE_U 6 /* write word in child's user structure */
|
||||
/* was PT_WRITE_U 6 * write word in child's user structure */
|
||||
#define PT_CONTINUE 7 /* continue the child */
|
||||
#define PT_KILL 8 /* kill the child process */
|
||||
#define PT_STEP 9 /* single step the child */
|
||||
|
Loading…
Reference in New Issue
Block a user