diff options
author | John Baldwin <jhb@FreeBSD.org> | 2020-04-01 19:22:09 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2020-04-01 19:22:09 +0000 |
commit | 59838c1a1979924f3904536f2e6d5a771e185c14 (patch) | |
tree | ce7764a4aa67665a70f2079c297f21e0d1225c33 | |
parent | 02cb5b4be86ed9827ddd8c39df5f48e6925c66d8 (diff) | |
download | src-test2-59838c1a1979924f3904536f2e6d5a771e185c14.tar.gz src-test2-59838c1a1979924f3904536f2e6d5a771e185c14.zip |
Notes
33 files changed, 23 insertions, 513 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 5f0067243f1e..872781642672 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -36,6 +36,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20200401: Remove procfs-based process debugging +OLD_FILES+=usr/include/sys/pioctl.h + # 20200330: GDB_LIBEXEC option retired (always true) OLD_FILES+=usr/bin/gdb OLD_FILES+=usr/bin/gdbserver diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile index b13c0f5770d5..d58858086bc9 100644 --- a/lib/libsysdecode/Makefile +++ b/lib/libsysdecode/Makefile @@ -119,11 +119,6 @@ CFLAGS+=-DPF # Workaround duplicate declarations in <netinet/ip_compat.h> CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls -# Ignore deprecation warning in <sys/pioctl.h> -CFLAGS.clang.ioctl.c+= -Wno-\#warnings -CFLAGS.gcc.ioctl.c+= -Wno-cpp - -CFLAGS.clang+= ${CFLAGS.clang.${.IMPSRC}} CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}} DEPENDOBJS+= tables.h diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index ecd2edc94a80..216cf15b0bf9 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -57,7 +57,6 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/systm.h> #include <sys/proc.h> -#include <sys/pioctl.h> #include <sys/ptrace.h> #include <sys/kdb.h> #include <sys/kernel.h> diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 60a252e0d6c1..37a71c9d58b6 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/mutex.h> -#include <sys/pioctl.h> #include <sys/priv.h> #include <sys/proc.h> #include <sys/procctl.h> @@ -198,15 +197,11 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) td2->td_frame->tf_rdx = 1; /* - * If the parent process has the trap bit set (i.e. a debugger had - * single stepped the process to the system call), we need to clear - * the trap flag from the new frame unless the debugger had set PF_FORK - * on the parent. Otherwise, the child will receive a (likely - * unexpected) SIGTRAP when it executes the first instruction after - * returning to userland. + * If the parent process has the trap bit set (i.e. a debugger + * had single stepped the process to the system call), we need + * to clear the trap flag from the new frame. */ - if ((p1->p_pfsflags & PF_FORK) == 0) - td2->td_frame->tf_rflags &= ~PSL_T; + td2->td_frame->tf_rflags &= ~PSL_T; /* * Set registers for trampoline to user mode. Leave space for the diff --git a/sys/amd64/ia32/ia32_reg.c b/sys/amd64/ia32/ia32_reg.c index 4a068b7f61e2..b4ad5833abc5 100644 --- a/sys/amd64/ia32/ia32_reg.c +++ b/sys/amd64/ia32/ia32_reg.c @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/mman.h> #include <sys/namei.h> -#include <sys/pioctl.h> #include <sys/proc.h> #include <sys/procfs.h> #include <sys/resourcevar.h> diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c index 4e32434797a1..0f2d874d142e 100644 --- a/sys/amd64/ia32/ia32_signal.c +++ b/sys/amd64/ia32/ia32_signal.c @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/mman.h> #include <sys/namei.h> -#include <sys/pioctl.h> #include <sys/proc.h> #include <sys/procfs.h> #include <sys/resourcevar.h> diff --git a/sys/amd64/ia32/ia32_syscall.c b/sys/amd64/ia32/ia32_syscall.c index 1bce6ad26513..4d08cfb43b63 100644 --- a/sys/amd64/ia32/ia32_syscall.c +++ b/sys/amd64/ia32/ia32_syscall.c @@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/systm.h> #include <sys/proc.h> -#include <sys/pioctl.h> #include <sys/kernel.h> #include <sys/ktr.h> #include <sys/lock.h> diff --git a/sys/arm/arm/syscall.c b/sys/arm/arm/syscall.c index 2500404d01f5..37824b7e1742 100644 --- a/sys/arm/arm/syscall.c +++ b/sys/arm/arm/syscall.c @@ -92,7 +92,6 @@ __FBSDID("$FreeBSD$"); #include <sys/sysent.h> #include <sys/signalvar.h> #include <sys/ptrace.h> -#include <sys/pioctl.h> #include <machine/frame.h> diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 629f9114cc04..9391e8ee0698 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); #include <sys/ktr.h> #include <sys/lock.h> #include <sys/mutex.h> -#include <sys/pioctl.h> #include <sys/proc.h> #include <sys/ptrace.h> #include <sys/syscall.h> diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c index d78f6b45ba80..cceb2b38b84c 100644 --- a/sys/compat/ia32/ia32_sysvec.c +++ b/sys/compat/ia32/ia32_sysvec.c @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/mman.h> #include <sys/namei.h> -#include <sys/pioctl.h> #include <sys/proc.h> #include <sys/procfs.h> #include <sys/resourcevar.h> diff --git a/sys/conf/files b/sys/conf/files index dd7e40c06edb..5dc45250a6f5 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -3517,7 +3517,6 @@ fs/nullfs/null_vnops.c optional nullfs fs/procfs/procfs.c optional procfs fs/procfs/procfs_dbregs.c optional procfs fs/procfs/procfs_fpregs.c optional procfs -fs/procfs/procfs_ioctl.c optional procfs fs/procfs/procfs_map.c optional procfs fs/procfs/procfs_mem.c optional procfs fs/procfs/procfs_note.c optional procfs diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index cfc4f5e8eb24..92208497231e 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -163,7 +163,6 @@ procfs_init(PFS_INIT_ARGS) { struct pfs_node *root; struct pfs_node *dir; - struct pfs_node *node; root = pi->pi_root; @@ -182,10 +181,8 @@ procfs_init(PFS_INIT_ARGS) procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); pfs_create_file(dir, "map", procfs_doprocmap, NULL, procfs_notsystem, NULL, PFS_RD); - node = pfs_create_file(dir, "mem", procfs_doprocmem, + pfs_create_file(dir, "mem", procfs_doprocmem, procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - node->pn_ioctl = procfs_ioctl; - node->pn_close = procfs_close; pfs_create_file(dir, "note", procfs_doprocnote, procfs_attr_w, procfs_candebug, NULL, PFS_WR); pfs_create_file(dir, "notepg", procfs_doprocnote, diff --git a/sys/fs/procfs/procfs.h b/sys/fs/procfs/procfs.h index bafcfab41aa0..6e6d3b0df079 100644 --- a/sys/fs/procfs/procfs.h +++ b/sys/fs/procfs/procfs.h @@ -53,8 +53,6 @@ int procfs_doprocregs(PFS_FILL_ARGS); int procfs_doprocrlimit(PFS_FILL_ARGS); int procfs_doprocstatus(PFS_FILL_ARGS); int procfs_doproctype(PFS_FILL_ARGS); -int procfs_ioctl(PFS_IOCTL_ARGS); -int procfs_close(PFS_CLOSE_ARGS); /* Attributes */ int procfs_attr_w(PFS_ATTR_ARGS); diff --git a/sys/fs/procfs/procfs_ioctl.c b/sys/fs/procfs/procfs_ioctl.c deleted file mode 100644 index 1c35906c7292..000000000000 --- a/sys/fs/procfs/procfs_ioctl.c +++ /dev/null @@ -1,263 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-3-Clause - * - * Copyright (c) 2001 Dag-Erling Coïdan Smørgrav - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#include <sys/param.h> -#include <sys/lock.h> -#include <sys/mutex.h> -#include <sys/pioctl.h> -#include <sys/priv.h> -#include <sys/proc.h> -#include <sys/signalvar.h> -#include <sys/systm.h> - -#include <fs/pseudofs/pseudofs.h> -#include <fs/procfs/procfs.h> - -#ifdef COMPAT_FREEBSD32 -struct procfs_status32 { - int state; /* Running, stopped, something else? */ - int flags; /* Any flags */ - unsigned int events; /* Events to stop on */ - int why; /* What event, if any, proc stopped on */ - unsigned int val; /* Any extra data */ -}; - -#define PIOCWAIT32 _IOR('p', 4, struct procfs_status32) -#define PIOCSTATUS32 _IOR('p', 6, struct procfs_status32) -#endif - -/* - * Process ioctls - */ -int -procfs_ioctl(PFS_IOCTL_ARGS) -{ - struct procfs_status *ps; -#ifdef COMPAT_FREEBSD32 - struct procfs_status32 *ps32; -#endif - int error, flags, sig; -#ifdef COMPAT_FREEBSD6 - int ival; -#endif - static struct timeval lasttime; - static struct timeval interval = { .tv_sec = 1, .tv_usec = 0 }; - - KASSERT(p != NULL, - ("%s() called without a process", __func__)); - PROC_LOCK_ASSERT(p, MA_OWNED); - - switch (cmd) { -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 1, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 1): -#endif - case PIOCBIS: -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 2, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 2): -#endif - case PIOCBIC: -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 3, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 3): -#endif - case PIOCSFL: - case PIOCGFL: - case PIOCWAIT: - case PIOCSTATUS: -#ifdef COMPAT_FREEBSD32 - case PIOCWAIT32: - case PIOCSTATUS32: -#endif -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 5, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 5): -#endif - case PIOCCONT: - if (ratecheck(&lasttime, &interval) != 0) - gone_in(13, "procfs-based process debugging"); - break; - } - - error = 0; - switch (cmd) { -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 1, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 1): - ival = IOCPARM_IVAL(data); - data = &ival; -#endif - case PIOCBIS: - p->p_stops |= *(unsigned int *)data; - break; -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 2, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 2): - ival = IOCPARM_IVAL(data); - data = &ival; -#endif - case PIOCBIC: - p->p_stops &= ~*(unsigned int *)data; - break; -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 3, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 3): - ival = IOCPARM_IVAL(data); - data = &ival; -#endif - case PIOCSFL: - flags = *(unsigned int *)data; - if (flags & PF_ISUGID) { - /* - * XXXRW: Is this specific check required here, as - * p_candebug() should implement it, or other checks - * are missing. - */ - error = priv_check(td, PRIV_DEBUG_SUGID); - if (error) - break; - } - p->p_pfsflags = flags; - break; - case PIOCGFL: - *(unsigned int *)data = p->p_pfsflags; - break; - case PIOCWAIT: - while (p->p_step == 0 && (p->p_flag & P_WEXIT) == 0) { - /* sleep until p stops */ - _PHOLD(p); - error = msleep(&p->p_stype, &p->p_mtx, - PWAIT|PCATCH, "pioctl", 0); - _PRELE(p); - if (error != 0) - break; - } - /* fall through to PIOCSTATUS */ - case PIOCSTATUS: - ps = (struct procfs_status *)data; - ps->state = (p->p_step == 0); - ps->flags = 0; /* nope */ - ps->events = p->p_stops; - ps->why = p->p_step ? p->p_stype : 0; - ps->val = p->p_step ? p->p_xsig : 0; - break; -#ifdef COMPAT_FREEBSD32 - case PIOCWAIT32: - while (p->p_step == 0 && (p->p_flag & P_WEXIT) == 0) { - /* sleep until p stops */ - _PHOLD(p); - error = msleep(&p->p_stype, &p->p_mtx, - PWAIT|PCATCH, "pioctl", 0); - _PRELE(p); - if (error != 0) - break; - } - /* fall through to PIOCSTATUS32 */ - case PIOCSTATUS32: - ps32 = (struct procfs_status32 *)data; - ps32->state = (p->p_step == 0); - ps32->flags = 0; /* nope */ - ps32->events = p->p_stops; - ps32->why = p->p_step ? p->p_stype : 0; - ps32->val = p->p_step ? p->p_xsig : 0; - break; -#endif -#if defined(COMPAT_FREEBSD5) || defined(COMPAT_FREEBSD4) || defined(COMPAT_43) - case _IOC(IOC_IN, 'p', 5, 0): -#endif -#ifdef COMPAT_FREEBSD6 - case _IO('p', 5): - ival = IOCPARM_IVAL(data); - data = &ival; -#endif - case PIOCCONT: - if (p->p_step == 0) - break; - sig = *(unsigned int *)data; - if (sig != 0 && !_SIG_VALID(sig)) { - error = EINVAL; - break; - } -#if 0 - p->p_step = 0; - if (P_SHOULDSTOP(p)) { - p->p_xsig = sig; - p->p_flag &= ~(P_STOPPED_TRACE|P_STOPPED_SIG); - PROC_SLOCK(p); - thread_unsuspend(p); - PROC_SUNLOCK(p); - } else if (sig) - kern_psignal(p, sig); -#else - if (sig) - kern_psignal(p, sig); - p->p_step = 0; - wakeup(&p->p_step); -#endif - break; - default: - error = (ENOTTY); - } - - return (error); -} - -/* - * Clean up on last close - */ -int -procfs_close(PFS_CLOSE_ARGS) -{ - if (p != NULL && (p->p_pfsflags & PF_LINGER) == 0) { - PROC_LOCK_ASSERT(p, MA_OWNED); - p->p_pfsflags = 0; - p->p_stops = 0; - p->p_step = 0; - wakeup(&p->p_step); - } - return (0); -} diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 54b28b80ef7f..ccf16bf009cd 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/systm.h> #include <sys/proc.h> -#include <sys/pioctl.h> #include <sys/ptrace.h> #include <sys/kdb.h> #include <sys/kernel.h> diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 62c7a6248641..a25c33b34d34 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$"); #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/mutex.h> -#include <sys/pioctl.h> #include <sys/proc.h> #include <sys/sysent.h> #include <sys/sf_buf.h> @@ -208,15 +207,11 @@ cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) td2->td_frame->tf_edx = 1; /* - * If the parent process has the trap bit set (i.e. a debugger had - * single stepped the process to the system call), we need to clear - * the trap flag from the new frame unless the debugger had set PF_FORK - * on the parent. Otherwise, the child will receive a (likely - * unexpected) SIGTRAP when it executes the first instruction after - * returning to userland. + * If the parent process has the trap bit set (i.e. a debugger + * had single stepped the process to the system call), we need + * to clear the trap flag from the new frame. */ - if ((p1->p_pfsflags & PF_FORK) == 0) - td2->td_frame->tf_eflags &= ~PSL_T; + td2->td_frame->tf_eflags &= ~PSL_T; /* * Set registers for trampoline to user mode. Leave space for the diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 5ba9f7e083de..bbd5fcd5249e 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include <sys/mount.h> #include <sys/mman.h> #include <sys/namei.h> -#include <sys/pioctl.h> #include <sys/proc.h> #include <sys/procfs.h> #include <sys/ptrace.h> diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 86ad8a8c9bbc..1e8cd39192fc 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include <sys/mount.h> #include <sys/mutex.h> #include <sys/namei.h> -#include <sys/pioctl.h> #include <sys/priv.h> #include <sys/proc.h> #include <sys/ptrace.h> @@ -912,12 +911,6 @@ exec_fail_dealloc: td->td_dbgflags |= TDB_EXEC; PROC_UNLOCK(p); } - - /* - * Stop the process here if its stop event mask has - * the S_EXEC bit set. - */ - STOPEVENT(p, S_EXEC, 0); } else { exec_fail: /* we're done here, clear P_INEXEC */ diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index d3adc9604ab4..244e1a2111ba 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/proc.h> #include <sys/procdesc.h> -#include <sys/pioctl.h> #include <sys/jail.h> #include <sys/tty.h> #include <sys/wait.h> @@ -281,15 +280,6 @@ exit1(struct thread *td, int rval, int signo) p->p_xsig = signo; /* - * Wakeup anyone in procfs' PIOCWAIT. They should have a hold - * on our vmspace, so we should block below until they have - * released their reference to us. Note that if they have - * requested S_EXIT stops we will block here until they ack - * via PIOCCONT. - */ - _STOPEVENT(p, S_EXIT, 0); - - /* * Ignore any pending request to stop due to a stop signal. * Once P_WEXIT is set, future requests will be ignored as * well. @@ -297,13 +287,8 @@ exit1(struct thread *td, int rval, int signo) p->p_flag &= ~P_STOPPED_SIG; KASSERT(!P_SHOULDSTOP(p), ("exiting process is stopped")); - /* - * Note that we are exiting and do another wakeup of anyone in - * PIOCWAIT in case they aren't listening for S_EXIT stops or - * decided to wait again after we told them we are exiting. - */ + /* Note that we are exiting. */ p->p_flag |= P_WEXIT; - wakeup(&p->p_stype); /* * Wait for any processes that have a hold on our vmspace to diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index d4c481b8f038..f94b7d31791b 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include <sys/priv.h> #include <sys/proc.h> #include <sys/procdesc.h> -#include <sys/pioctl.h> #include <sys/ptrace.h> #include <sys/racct.h> #include <sys/resourcevar.h> @@ -583,15 +582,6 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread * callout_init_mtx(&p2->p_itcallout, &p2->p_mtx, 0); /* - * If PF_FORK is set, the child process inherits the - * procfs ioctl flags from its parent. - */ - if (p1->p_pfsflags & PF_FORK) { - p2->p_stops = p1->p_stops; - p2->p_pfsflags = p1->p_pfsflags; - } - - /* * This begins the section where we must prevent the parent * from being swapped. */ @@ -1111,7 +1101,6 @@ fork_return(struct thread *td, struct trapframe *frame) */ PROC_LOCK(p); td->td_dbgflags |= TDB_SCX; - _STOPEVENT(p, S_SCX, td->td_sa.code); if ((p->p_ptevents & PTRACE_SCX) != 0 || (td->td_dbgflags & TDB_BORN) != 0) ptracestop(td, SIGTRAP, NULL); diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index bd26317599d8..a3e7b162e100 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #include <sys/sysent.h> #include <sys/sysproto.h> #include <sys/jail.h> -#include <sys/pioctl.h> #include <sys/racct.h> #include <sys/rctl.h> #include <sys/resourcevar.h> @@ -2192,8 +2191,6 @@ setsugid(struct proc *p) PROC_LOCK_ASSERT(p, MA_OWNED); p->p_flag |= P_SUGID; - if (!(p->p_pfsflags & PF_ISUGID)) - p->p_stops = 0; } /*- diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 0d597e559c8d..d36c382d3e23 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -67,7 +67,6 @@ __FBSDID("$FreeBSD$"); #include <sys/procdesc.h> #include <sys/ptrace.h> #include <sys/posix4.h> -#include <sys/pioctl.h> #include <sys/racct.h> #include <sys/resourcevar.h> #include <sys/sdt.h> @@ -2256,14 +2255,6 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) !((prop & SIGPROP_CONT) && (p->p_flag & P_STOPPED_SIG))) return (ret); - /* SIGKILL: Remove procfs STOPEVENTs. */ - if (sig == SIGKILL) { - /* from procfs_ioctl.c: PIOCBIC */ - p->p_stops = 0; - /* from procfs_ioctl.c: PIOCCONT */ - p->p_step = 0; - wakeup(&p->p_step); - } wakeup_swapper = 0; /* @@ -2853,15 +2844,13 @@ issignal(struct thread *td) struct sigqueue *queue; sigset_t sigpending; ksiginfo_t ksi; - int prop, sig, traced; + int prop, sig; p = td->td_proc; ps = p->p_sigacts; mtx_assert(&ps->ps_mtx, MA_OWNED); PROC_LOCK_ASSERT(p, MA_OWNED); for (;;) { - traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG); - sigpending = td->td_sigqueue.sq_signals; SIGSETOR(sigpending, p->p_sigqueue.sq_signals); SIGSETNAND(sigpending, td->td_sigmask); @@ -2904,17 +2893,12 @@ issignal(struct thread *td) sig = sig_ffs(&sigpending); } - if (p->p_stops & S_SIG) { - mtx_unlock(&ps->ps_mtx); - stopevent(p, S_SIG, sig); - mtx_lock(&ps->ps_mtx); - } - /* * We should see pending but ignored signals * only if P_TRACED was on when they were posted. */ - if (SIGISMEMBER(ps->ps_sigignore, sig) && (traced == 0)) { + if (SIGISMEMBER(ps->ps_sigignore, sig) && + (p->p_flag & P_TRACED) == 0) { sigqueue_delete(&td->td_sigqueue, sig); sigqueue_delete(&p->p_sigqueue, sig); continue; @@ -3114,11 +3098,6 @@ postsig(int sig) ktrpsig(sig, action, td->td_pflags & TDP_OLDMASK ? &td->td_oldsigmask : &td->td_sigmask, ksi.ksi_code); #endif - if ((p->p_stops & S_SIG) != 0) { - mtx_unlock(&ps->ps_mtx); - stopevent(p, S_SIG, sig); - mtx_lock(&ps->ps_mtx); - } if (action == SIG_DFL) { /* @@ -3665,7 +3644,6 @@ coredump(struct thread *td) PROC_LOCK_ASSERT(p, MA_OWNED); MPASS((p->p_flag & P_HADTHREADS) == 0 || p->p_singlethread == td); - _STOPEVENT(p, S_CORE, 0); if (!do_coredump || (!sugid_coredump && (p->p_flag & P_SUGID) != 0) || (p->p_flag2 & P2_NOTRACE) != 0) { diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 2169c4b2697e..56fb31f4dada 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -90,11 +90,11 @@ _Static_assert(offsetof(struct proc, p_flag) == 0xb0, "struct proc KBI p_flag"); _Static_assert(offsetof(struct proc, p_pid) == 0xbc, "struct proc KBI p_pid"); -_Static_assert(offsetof(struct proc, p_filemon) == 0x3c8, +_Static_assert(offsetof(struct proc, p_filemon) == 0x3c0, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x3e0, +_Static_assert(offsetof(struct proc, p_comm) == 0x3d8, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x4c0, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x4b8, "struct proc KBI p_emuldata"); #endif #ifdef __i386__ @@ -110,11 +110,11 @@ _Static_assert(offsetof(struct proc, p_flag) == 0x68, "struct proc KBI p_flag"); _Static_assert(offsetof(struct proc, p_pid) == 0x74, "struct proc KBI p_pid"); -_Static_assert(offsetof(struct proc, p_filemon) == 0x278, +_Static_assert(offsetof(struct proc, p_filemon) == 0x26c, "struct proc KBI p_filemon"); -_Static_assert(offsetof(struct proc, p_comm) == 0x28c, +_Static_assert(offsetof(struct proc, p_comm) == 0x280, "struct proc KBI p_comm"); -_Static_assert(offsetof(struct proc, p_emuldata) == 0x318, +_Static_assert(offsetof(struct proc, p_emuldata) == 0x30c, "struct proc KBI p_emuldata"); #endif diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index a67a0a28ba39..cfd3496e81b2 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -90,7 +90,6 @@ syscallenter(struct thread *td) goto retval; } - STOPEVENT(p, S_SCE, sa->narg); if (__predict_false((p->p_flag & P_TRACED) != 0)) { PROC_LOCK(p); if (p->p_ptevents & PTRACE_SCE) @@ -223,12 +222,6 @@ syscallret(struct thread *td) td->td_dbgflags |= TDB_SCX; PROC_UNLOCK(p); } - /* - * This works because errno is findable through the - * register set. If we ever support an emulation where this - * is not the case, this code will need to be revisited. - */ - STOPEVENT(p, S_SCX, sa->code); if (__predict_false(traced || (td->td_dbgflags & (TDB_EXEC | TDB_FORK)) != 0)) { PROC_LOCK(p); diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index b79d32dfda6d..08d8d2cb2239 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$"); #include <sys/pmckern.h> #include <sys/proc.h> #include <sys/ktr.h> -#include <sys/pioctl.h> #include <sys/ptrace.h> #include <sys/racct.h> #include <sys/resourcevar.h> diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 09db10c9ced3..01583c7c97f9 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$"); #include <sys/syscallsubr.h> #include <sys/sysent.h> #include <sys/sysproto.h> -#include <sys/pioctl.h> #include <sys/priv.h> #include <sys/proc.h> #include <sys/vnode.h> @@ -1524,26 +1523,3 @@ fail: } #undef PROC_READ #undef PROC_WRITE - -/* - * Stop a process because of a debugging event; - * stay stopped until p->p_step is cleared - * (cleared by PIOCCONT in procfs). - */ -void -stopevent(struct proc *p, unsigned int event, unsigned int val) -{ - - PROC_LOCK_ASSERT(p, MA_OWNED); - p->p_step = 1; - CTR3(KTR_PTRACE, "stopevent: pid %d event %u val %u", p->p_pid, event, - val); - do { - if (event != S_EXIT) - p->p_xsig = val; - p->p_xthread = NULL; - p->p_stype = event; /* Which event caused the stop? */ - wakeup(&p->p_stype); /* Wake up any PIOCWAIT'ing procs */ - msleep(&p->p_step, &p->p_mtx, PWAIT, "stopevent", 0); - } while (p->p_step); -} diff --git a/sys/mips/mips/trap.c b/sys/mips/mips/trap.c index 2a5d67c36f91..ff8f51f67698 100644 --- a/sys/mips/mips/trap.c +++ b/sys/mips/mips/trap.c @@ -66,7 +66,6 @@ __FBSDID("$FreeBSD$"); #include <sys/user.h> #include <sys/buf.h> #include <sys/vnode.h> -#include <sys/pioctl.h> #include <sys/sysctl.h> #include <sys/syslog.h> #include <sys/bus.h> diff --git a/sys/modules/procfs/Makefile b/sys/modules/procfs/Makefile index 5a819e2cae4b..282b200e5a60 100644 --- a/sys/modules/procfs/Makefile +++ b/sys/modules/procfs/Makefile @@ -7,7 +7,6 @@ SRCS= SRCS+= vnode_if.h SRCS+= procfs_dbregs.c SRCS+= procfs_fpregs.c -SRCS+= procfs_ioctl.c SRCS+= procfs_map.c SRCS+= procfs_mem.c SRCS+= procfs_note.c diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index 6529cdf76c88..7b5ed1aa45b3 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include <sys/ktr.h> #include <sys/lock.h> #include <sys/mutex.h> -#include <sys/pioctl.h> #include <sys/ptrace.h> #include <sys/reboot.h> #include <sys/syscall.h> diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index f6d547fe5f3f..e1d8bb76e2df 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include <sys/ktr.h> #include <sys/lock.h> #include <sys/mutex.h> -#include <sys/pioctl.h> #include <sys/bus.h> #include <sys/proc.h> #include <sys/ptrace.h> diff --git a/sys/sys/param.h b/sys/sys/param.h index 5c7a23ce7fa7..ec088bdbbd7e 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300087 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300088 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/pioctl.h b/sys/sys/pioctl.h deleted file mode 100644 index ed8a93a3be09..000000000000 --- a/sys/sys/pioctl.h +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-4-Clause - * - * Copyright 1997 Sean Eric Fagan - * - * 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. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Sean Eric Fagan - * 4. Neither the name of the author may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 ioctl definitions. - * - * $FreeBSD$ - */ - -#ifndef _SYS_PIOCTL_H -# define _SYS_PIOCTL_H - -#ifndef _KERNEL -#warning "<sys/pioctl.h> is deprecated, ptrace() should be used instead" -#endif - -# include <sys/ioccom.h> - -struct procfs_status { - int state; /* Running, stopped, something else? */ - int flags; /* Any flags */ - unsigned long events; /* Events to stop on */ - int why; /* What event, if any, proc stopped on */ - unsigned long val; /* Any extra data */ -}; - -# define PIOCBIS _IOWINT('p', 1) /* Set event flag */ -# define PIOCBIC _IOWINT('p', 2) /* Clear event flag */ -# define PIOCSFL _IOWINT('p', 3) /* Set flags */ - /* wait for proc to stop */ -# define PIOCWAIT _IOR('p', 4, struct procfs_status) -# define PIOCCONT _IOWINT('p', 5) /* Continue a process */ - /* Get proc status */ -# define PIOCSTATUS _IOR('p', 6, struct procfs_status) -# define PIOCGFL _IOR('p', 7, unsigned int) /* Get flags */ - -# define S_EXEC 0x00000001 /* stop-on-exec */ -# define S_SIG 0x00000002 /* stop-on-signal */ -# define S_SCE 0x00000004 /* stop on syscall entry */ -# define S_SCX 0x00000008 /* stop on syscall exit */ -# define S_CORE 0x00000010 /* stop on coredump */ -# define S_EXIT 0x00000020 /* stop on exit */ -# define S_ALLSTOPS 0x003f /* stop on all events */ - -/* - * If PF_LINGER is set in procp->p_pfsflags, then the last close - * of a /proc/<pid>/mem file will not clear out the stops and continue - * the process. - */ - -# define PF_LINGER 0x01 /* Keep stops around after last close */ -# define PF_ISUGID 0x02 /* Ignore UID/GID changes */ -# define PF_FORK 0x04 /* Retain settings on fork() */ -#endif diff --git a/sys/sys/proc.h b/sys/sys/proc.h index bbae5cf1caae..48610210c95a 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -644,10 +644,6 @@ struct proc { struct sigiolst p_sigiolst; /* (c) List of sigio sources. */ int p_sigparent; /* (c) Signal to parent on exit. */ int p_sig; /* (n) For core dump/debugger XXX. */ - u_int p_stops; /* (c) Stop event bitmask. */ - u_int p_stype; /* (c) Stop event type. */ - char p_step; /* (c) Process is stopped. */ - u_char p_pfsflags; /* (c) Procfs flags. */ u_int p_ptevents; /* (c + e) ptrace() event mask. */ struct nlminfo *p_nlminfo; /* (?) Only used by/for lockd. */ struct kaioinfo *p_aioinfo; /* (y) ASYNC I/O info. */ @@ -864,23 +860,6 @@ extern pid_t pid_max; #define SESS_LEADER(p) ((p)->p_session->s_leader == (p)) -#define STOPEVENT(p, e, v) do { \ - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, \ - "checking stopevent %d", (e)); \ - if ((p)->p_stops & (e)) { \ - PROC_LOCK(p); \ - stopevent((p), (e), (v)); \ - PROC_UNLOCK(p); \ - } \ -} while (0) -#define _STOPEVENT(p, e, v) do { \ - PROC_LOCK_ASSERT(p, MA_OWNED); \ - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, &p->p_mtx.lock_object, \ - "checking stopevent %d", (e)); \ - if ((p)->p_stops & (e)) \ - stopevent((p), (e), (v)); \ -} while (0) - /* Lock and unlock a process. */ #define PROC_LOCK(p) mtx_lock(&(p)->p_mtx) #define PROC_TRYLOCK(p) mtx_trylock(&(p)->p_mtx) |