diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2005-04-16 22:19:29 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2005-04-16 22:19:29 +0000 |
commit | 86718cb35d929cb9692f5bda49aa9cae99483179 (patch) | |
tree | 13b91791b7ceb49b987d1be1327ec995769feb55 | |
parent | 8cfe6a4577283fbd292e70a1dfb76eff3191c45e (diff) |
Remove regs and fpregs pseudo-files from procfs.
ok deraadt@, miod@
-rw-r--r-- | sys/conf/files | 4 | ||||
-rw-r--r-- | sys/kern/sys_process.c | 90 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_fpregs.c | 108 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_regs.c | 100 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_subr.c | 10 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 6 |
6 files changed, 52 insertions, 266 deletions
diff --git a/sys/conf/files b/sys/conf/files index 9f3c1181b8d..1d3f54754ec 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.333 2005/03/29 17:27:30 deraadt Exp $ +# $OpenBSD: files,v 1.334 2005/04/16 22:19:28 kettenis Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -667,11 +667,9 @@ file miscfs/portal/portal_vfsops.c portal file miscfs/portal/portal_vnops.c portal file miscfs/procfs/procfs_cmdline.c procfs file miscfs/procfs/procfs_ctl.c procfs -file miscfs/procfs/procfs_fpregs.c ptrace file miscfs/procfs/procfs_linux.c procfs file miscfs/procfs/procfs_mem.c file miscfs/procfs/procfs_note.c procfs -file miscfs/procfs/procfs_regs.c ptrace file miscfs/procfs/procfs_status.c procfs file miscfs/procfs/procfs_subr.c procfs file miscfs/procfs/procfs_vfsops.c procfs diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 1498a10c954..58ea0e73b3f 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.29 2005/04/03 20:21:44 kettenis Exp $ */ +/* $OpenBSD: sys_process.c,v 1.30 2005/04/16 22:19:28 kettenis Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -87,6 +87,10 @@ sys_ptrace(p, v, retval) struct uio uio; struct iovec iov; struct ptrace_io_desc piod; + struct reg regs; +#if defined (PT_SETFPREGS) || defined (PT_GETFPREGS) + struct fpreg fpregs; +#endif #if defined (PT_SETXMMREGS) || defined (PT_GETXMMREGS) struct xmmregs xmmregs; #endif @@ -400,52 +404,58 @@ sys_ptrace(p, v, retval) goto sendsig; case PT_SETREGS: - write = 1; + KASSERT((p->p_flag & P_SYSTEM) == 0); + if ((error = procfs_checkioperm(p, t)) != 0) + return (error); + + error = copyin(SCARG(uap, addr), ®s, sizeof(regs)); + if (error) + return (error); + PHOLD(p); + error = process_write_regs(t, ®s); + PRELE(p); + return (error); case PT_GETREGS: - /* write = 0 done above. */ - if (!procfs_validregs(t, NULL)) - return (EINVAL); - else { - iov.iov_base = SCARG(uap, addr); - iov.iov_len = sizeof(struct reg); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = 0; - uio.uio_resid = sizeof(struct reg); - uio.uio_segflg = UIO_USERSPACE; - uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = p; - return (procfs_doregs(p, t, NULL, &uio)); - } + KASSERT((p->p_flag & P_SYSTEM) == 0); + if ((error = procfs_checkioperm(p, t)) != 0) + return (error); + + PHOLD(p); + error = process_read_regs(t, ®s); + PRELE(p); + if (error) + return (error); + return (copyout(®s, SCARG(uap, addr), sizeof (regs))); #ifdef PT_SETFPREGS case PT_SETFPREGS: - write = 1; + KASSERT((p->p_flag & P_SYSTEM) == 0); + if ((error = procfs_checkioperm(p, t)) != 0) + return (error); + + error = copyin(SCARG(uap, addr), &fpregs, sizeof(fpregs)); + if (error) + return (error); + PHOLD(p); + error = process_write_fpregs(t, &fpregs); + PRELE(p); + return (error); #endif #ifdef PT_GETFPREGS case PT_GETFPREGS: - /* write = 0 done above. */ -#endif -#if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) - if (!procfs_validfpregs(t, NULL)) - return (EINVAL); - else { - iov.iov_base = SCARG(uap, addr); - iov.iov_len = sizeof(struct fpreg); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = 0; - uio.uio_resid = sizeof(struct fpreg); - uio.uio_segflg = UIO_USERSPACE; - uio.uio_rw = write ? UIO_WRITE : UIO_READ; - uio.uio_procp = p; - return (procfs_dofpregs(p, t, NULL, &uio)); - } + KASSERT((p->p_flag & P_SYSTEM) == 0); + if ((error = procfs_checkioperm(p, t)) != 0) + return (error); + + PHOLD(p); + error = process_read_fpregs(t, &fpregs); + PRELE(p); + if (error) + return (error); + return (copyout(&fpregs, SCARG(uap, addr), sizeof (fpregs))); #endif #ifdef PT_SETXMMREGS case PT_SETXMMREGS: - if (!procfs_validfpregs(t, NULL)) - return (EINVAL); - + KASSERT((p->p_flag & P_SYSTEM) == 0); if ((error = procfs_checkioperm(p, t)) != 0) return (error); @@ -459,9 +469,7 @@ sys_ptrace(p, v, retval) #endif #ifdef PT_GETXMMREGS case PT_GETXMMREGS: - if (!procfs_validfpregs(t, NULL)) - return (EINVAL); - + KASSERT((p->p_flag & P_SYSTEM) == 0); if ((error = procfs_checkioperm(p, t)) != 0) return (error); diff --git a/sys/miscfs/procfs/procfs_fpregs.c b/sys/miscfs/procfs/procfs_fpregs.c deleted file mode 100644 index a4f91348007..00000000000 --- a/sys/miscfs/procfs/procfs_fpregs.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $OpenBSD: procfs_fpregs.c,v 1.7 2004/05/05 23:52:10 tedu Exp $ */ -/* $NetBSD: procfs_fpregs.c,v 1.4 1995/08/13 09:06:05 mycroft Exp $ */ - -/* - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_fpregs.c 8.2 (Berkeley) 6/15/94 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/time.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/vnode.h> -#include <sys/ptrace.h> -#include <machine/reg.h> -#include <miscfs/procfs/procfs.h> - -int -procfs_dofpregs(curp, p, pfs, uio) - struct proc *curp; /* tracer */ - struct proc *p; /* traced */ - struct pfsnode *pfs; - struct uio *uio; -{ -#if defined(PT_GETFPREGS) || defined(PT_SETFPREGS) - int error; - struct fpreg r; - char *kv; - int kl; - - if ((error = procfs_checkioperm(curp, p)) != 0) - return (error); - - kl = sizeof(r); - kv = (char *)&r; - - kv += uio->uio_offset; - kl -= uio->uio_offset; - if (kl > uio->uio_resid) - kl = uio->uio_resid; - - PHOLD(p); - - if (uio->uio_offset > (off_t)sizeof(r)) - error = EINVAL; - else - error = process_read_fpregs(p, &r); - if (error == 0) - error = uiomove(kv, kl, uio); - if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) - error = EBUSY; - else - error = process_write_fpregs(p, &r); - } - - PRELE(p); - - uio->uio_offset = 0; - return (error); -#else - return (EINVAL); -#endif -} - -int -procfs_validfpregs(p, mp) - struct proc *p; - struct mount *mp; -{ - -#if defined(PT_SETFPREGS) || defined(PT_GETFPREGS) - return ((p->p_flag & P_SYSTEM) == 0); -#else - return (0); -#endif -} diff --git a/sys/miscfs/procfs/procfs_regs.c b/sys/miscfs/procfs/procfs_regs.c deleted file mode 100644 index 5fe351ca511..00000000000 --- a/sys/miscfs/procfs/procfs_regs.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $OpenBSD: procfs_regs.c,v 1.8 2004/05/05 23:52:10 tedu Exp $ */ -/* $NetBSD: procfs_regs.c,v 1.9 1995/08/13 09:06:07 mycroft Exp $ */ - -/* - * Copyright (c) 1993 Jan-Simon Pendry - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)procfs_regs.c 8.4 (Berkeley) 6/15/94 - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/time.h> -#include <sys/kernel.h> -#include <sys/proc.h> -#include <sys/vnode.h> -#include <sys/ptrace.h> -#include <machine/reg.h> -#include <miscfs/procfs/procfs.h> - -int -procfs_doregs(curp, p, pfs, uio) - struct proc *curp; /* tracer */ - struct proc *p; /* traced */ - struct pfsnode *pfs; - struct uio *uio; -{ - int error; - struct reg r; - char *kv; - int kl; - - if ((error = procfs_checkioperm(curp, p)) != 0) - return (error); - - kl = sizeof(r); - kv = (char *)&r; - - kv += uio->uio_offset; - kl -= uio->uio_offset; - if (kl > uio->uio_resid) - kl = uio->uio_resid; - - PHOLD(p); - - if (uio->uio_offset > (off_t)sizeof(r)) - error = EINVAL; - else - error = process_read_regs(p, &r); - if (error == 0) - error = uiomove(kv, kl, uio); - if (error == 0 && uio->uio_rw == UIO_WRITE) { - if (p->p_stat != SSTOP) - error = EBUSY; - else - error = process_write_regs(p, &r); - } - - PRELE(p); - - uio->uio_offset = 0; - return (error); -} - -int -procfs_validregs(p, mp) - struct proc *p; - struct mount *mp; -{ - - return ((p->p_flag & P_SYSTEM) == 0); -} diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c index a7f9ff5f06f..ea58588ee0b 100644 --- a/sys/miscfs/procfs/procfs_subr.c +++ b/sys/miscfs/procfs/procfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_subr.c,v 1.21 2004/05/05 23:52:10 tedu Exp $ */ +/* $OpenBSD: procfs_subr.c,v 1.22 2005/04/16 22:19:28 kettenis Exp $ */ /* $NetBSD: procfs_subr.c,v 1.15 1996/02/12 15:01:42 christos Exp $ */ /* @@ -222,14 +222,6 @@ procfs_rw(v) case Pnotepg: return (procfs_donote(curp, p, pfs, uio)); -#ifdef PTRACE - case Pregs: - return (procfs_doregs(curp, p, pfs, uio)); - - case Pfpregs: - return (procfs_dofpregs(curp, p, pfs, uio)); -#endif - case Pctl: return (procfs_doctl(curp, p, pfs, uio)); diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index 03f8f295d5d..a9125261db2 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_vnops.c,v 1.34 2005/04/01 20:16:01 pedro Exp $ */ +/* $OpenBSD: procfs_vnops.c,v 1.35 2005/04/16 22:19:28 kettenis Exp $ */ /* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */ /* @@ -86,10 +86,6 @@ struct proc_target { { DT_DIR, N(".."), Proot, NULL }, { DT_REG, N("file"), Pfile, procfs_validfile }, { DT_REG, N("mem"), Pmem, NULL }, -#ifdef PTRACE - { DT_REG, N("regs"), Pregs, procfs_validregs }, - { DT_REG, N("fpregs"), Pfpregs, procfs_validfpregs }, -#endif { DT_REG, N("ctl"), Pctl, NULL }, { DT_REG, N("status"), Pstatus, NULL }, { DT_REG, N("note"), Pnote, NULL }, |