Retire procfs-based process debugging.
Modern debuggers and process tracers use ptrace() rather than procfs for debugging. ptrace() has a supserset of functionality available via procfs and new debugging features are only added to ptrace(). While the two debugging services share some fields in struct proc, they each use dedicated fields and separate code. This results in extra complexity to support a feature that hasn't been enabled in the default install for several years. PR: 244939 (exp-run) Reviewed by: kib, mjg (earlier version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D23837
This commit is contained in:
parent
02cb5b4be8
commit
59838c1a19
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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,14 +197,10 @@ 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;
|
||||
|
||||
/*
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
@ -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>
|
||||
|
@ -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,14 +207,10 @@ 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;
|
||||
|
||||
/*
|
||||
|
@ -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>
|
||||
|
@ -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 @@ do_execve(struct thread *td, struct image_args *args, struct mac *mac_p)
|
||||
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 */
|
||||
|
@ -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>
|
||||
@ -280,15 +279,6 @@ exit1(struct thread *td, int rval, int signo)
|
||||
p->p_xexit = rval;
|
||||
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
|
||||
@ -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
|
||||
|
@ -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>
|
||||
@ -582,15 +581,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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/*-
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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>
|
||||
|
@ -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 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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,
|
||||
|
@ -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
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user