From 2aca0c28d39b914923402cc81a4d6b4213b3df2d Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Wed, 8 Aug 2001 05:25:15 +0000 Subject: 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. --- sys/alpha/alpha/machdep.c | 56 ------------------------------------------- sys/alpha/include/ptrace.h | 6 ----- sys/amd64/amd64/machdep.c | 54 ----------------------------------------- sys/amd64/include/ptrace.h | 5 ---- sys/i386/i386/machdep.c | 54 ----------------------------------------- sys/i386/include/ptrace.h | 5 ---- sys/ia64/ia64/machdep.c | 53 ---------------------------------------- sys/ia64/include/ptrace.h | 5 ---- sys/kern/sys_process.c | 43 --------------------------------- sys/pc98/i386/machdep.c | 54 ----------------------------------------- sys/pc98/pc98/machdep.c | 54 ----------------------------------------- sys/powerpc/aim/machdep.c | 16 ------------- sys/powerpc/include/ptrace.h | 5 ---- sys/powerpc/powerpc/machdep.c | 16 ------------- sys/sparc64/include/ptrace.h | 2 -- sys/sparc64/sparc64/machdep.c | 14 ----------- sys/sys/ptrace.h | 4 ++-- 17 files changed, 2 insertions(+), 444 deletions(-) (limited to 'sys') diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index f1c21bb58712..490ea29c838c 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -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) { diff --git a/sys/alpha/include/ptrace.h b/sys/alpha/include/ptrace.h index 2af0ec498c9e..3dca2aa6debf 100644 --- a/sys/alpha/include/ptrace.h +++ b/sys/alpha/include/ptrace.h @@ -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 - diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index a7f53eb3804c..41d0411d442a 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -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; diff --git a/sys/amd64/include/ptrace.h b/sys/amd64/include/ptrace.h index d59a38f3409b..ea3477e11d81 100644 --- a/sys/amd64/include/ptrace.h +++ b/sys/amd64/include/ptrace.h @@ -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 - diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index a7f53eb3804c..41d0411d442a 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -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; diff --git a/sys/i386/include/ptrace.h b/sys/i386/include/ptrace.h index d59a38f3409b..ea3477e11d81 100644 --- a/sys/i386/include/ptrace.h +++ b/sys/i386/include/ptrace.h @@ -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 - diff --git a/sys/ia64/ia64/machdep.c b/sys/ia64/ia64/machdep.c index 1bf4a78cb116..f91578232c03 100644 --- a/sys/ia64/ia64/machdep.c +++ b/sys/ia64/ia64/machdep.c @@ -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) { diff --git a/sys/ia64/include/ptrace.h b/sys/ia64/include/ptrace.h index 8a7ff84fd594..2cf8f264b660 100644 --- a/sys/ia64/include/ptrace.h +++ b/sys/ia64/include/ptrace.h @@ -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 - diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 66d7e675b33a..a81a768011c7 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -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 */ diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index 86b6db25fd58..48eef4944f1c 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -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; diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 86b6db25fd58..48eef4944f1c 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -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; diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c index 3427d8380b2f..586210b9466f 100644 --- a/sys/powerpc/aim/machdep.c +++ b/sys/powerpc/aim/machdep.c @@ -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) { diff --git a/sys/powerpc/include/ptrace.h b/sys/powerpc/include/ptrace.h index d59a38f3409b..ea3477e11d81 100644 --- a/sys/powerpc/include/ptrace.h +++ b/sys/powerpc/include/ptrace.h @@ -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 - diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c index 3427d8380b2f..586210b9466f 100644 --- a/sys/powerpc/powerpc/machdep.c +++ b/sys/powerpc/powerpc/machdep.c @@ -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) { diff --git a/sys/sparc64/include/ptrace.h b/sys/sparc64/include/ptrace.h index 8dde79ecf358..d5913a517b02 100644 --- a/sys/sparc64/include/ptrace.h +++ b/sys/sparc64/include/ptrace.h @@ -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_ */ diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index faacd0de5cdd..361f21d94c0c 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -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) { diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h index dcbafc242048..71f6013d49a7 100644 --- a/sys/sys/ptrace.h +++ b/sys/sys/ptrace.h @@ -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 */ -- cgit v1.2.3