FreeBSD kernel kern code
sys_process.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ktr.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/reg.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/ptrace.h>
#include <sys/rwlock.h>
#include <sys/sx.h>
#include <sys/malloc.h>
#include <sys/signalvar.h>
#include <sys/caprights.h>
#include <sys/filedesc.h>
#include <security/audit/audit.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
#include <vm/vm_kern.h>
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_param.h>
Include dependency graph for sys_process.c:

Go to the source code of this file.

Data Structures

struct  ptrace_args
 

Macros

#define PROC_ASSERT_TRACEREQ(p)   MPASS(((p)->p_flag2 & P2_PTRACEREQ) != 0)
 
#define PROC_ACTION(action)
 
#define PROC_READ(w, t, a)   proc_read_ ## w (t, a)
 
#define PROC_WRITE(w, t, a)   proc_write_ ## w (t, a)
 

Functions

 __FBSDID ("$FreeBSD$")
 
int proc_read_regs (struct thread *td, struct reg *regs)
 
int proc_write_regs (struct thread *td, struct reg *regs)
 
int proc_read_dbregs (struct thread *td, struct dbreg *dbregs)
 
int proc_write_dbregs (struct thread *td, struct dbreg *dbregs)
 
int proc_read_fpregs (struct thread *td, struct fpreg *fpregs)
 
int proc_write_fpregs (struct thread *td, struct fpreg *fpregs)
 
static struct regset * proc_find_regset (struct thread *td, int note)
 
static int proc_read_regset (struct thread *td, int note, struct iovec *iov)
 
static int proc_write_regset (struct thread *td, int note, struct iovec *iov)
 
int proc_sstep (struct thread *td)
 
int proc_rwmem (struct proc *p, struct uio *uio)
 
static ssize_t proc_iop (struct thread *td, struct proc *p, vm_offset_t va, void *buf, size_t len, enum uio_rw rw)
 
ssize_t proc_readmem (struct thread *td, struct proc *p, vm_offset_t va, void *buf, size_t len)
 
ssize_t proc_writemem (struct thread *td, struct proc *p, vm_offset_t va, void *buf, size_t len)
 
static int ptrace_vm_entry (struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
 
int sys_ptrace (struct thread *td, struct ptrace_args *uap)
 
void proc_set_traced (struct proc *p, bool stop)
 
void ptrace_unsuspend (struct proc *p)
 
static int proc_can_ptrace (struct thread *td, struct proc *p)
 
static struct thread * ptrace_sel_coredump_thread (struct proc *p)
 
int kern_ptrace (struct thread *td, int req, pid_t pid, void *addr, int data)
 

Macro Definition Documentation

◆ PROC_ACTION

#define PROC_ACTION (   action)
Value:
do { \
int error; \
\
PROC_LOCK_ASSERT(td->td_proc, MA_OWNED); \
if ((td->td_proc->p_flag & P_INMEM) == 0) \
error = EIO; \
else \
error = (action); \
return (error); \
} while (0)

Definition at line 102 of file sys_process.c.

◆ PROC_ASSERT_TRACEREQ

#define PROC_ASSERT_TRACEREQ (   p)    MPASS(((p)->p_flag2 & P2_PTRACEREQ) != 0)

Definition at line 74 of file sys_process.c.

◆ PROC_READ

#define PROC_READ (   w,
  t,
 
)    proc_read_ ## w (t, a)

Definition at line 729 of file sys_process.c.

◆ PROC_WRITE

#define PROC_WRITE (   w,
  t,
 
)    proc_write_ ## w (t, a)

Definition at line 730 of file sys_process.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ kern_ptrace()

◆ proc_can_ptrace()

static int proc_can_ptrace ( struct thread *  td,
struct proc *  p 
)
static

Definition at line 759 of file sys_process.c.

References p_candebug(), and p_cansee().

Referenced by kern_ptrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_find_regset()

static struct regset * proc_find_regset ( struct thread *  td,
int  note 
)
static

Definition at line 160 of file sys_process.c.

Referenced by proc_read_regset(), and proc_write_regset().

Here is the caller graph for this function:

◆ proc_iop()

static ssize_t proc_iop ( struct thread *  td,
struct proc *  p,
vm_offset_t  va,
void *  buf,
size_t  len,
enum uio_rw  rw 
)
static

Definition at line 418 of file sys_process.c.

References buf, and proc_rwmem().

Referenced by proc_readmem(), and proc_writemem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_read_dbregs()

int proc_read_dbregs ( struct thread *  td,
struct dbreg *  dbregs 
)

Definition at line 128 of file sys_process.c.

References PROC_ACTION.

◆ proc_read_fpregs()

int proc_read_fpregs ( struct thread *  td,
struct fpreg *  fpregs 
)

Definition at line 146 of file sys_process.c.

References PROC_ACTION.

◆ proc_read_regs()

int proc_read_regs ( struct thread *  td,
struct reg *  regs 
)

Definition at line 114 of file sys_process.c.

References PROC_ACTION.

◆ proc_read_regset()

static int proc_read_regset ( struct thread *  td,
int  note,
struct iovec *  iov 
)
static

Definition at line 183 of file sys_process.c.

References buf, free(), malloc(), PROC_ASSERT_TRACEREQ, and proc_find_regset().

Referenced by kern_ptrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_readmem()

ssize_t proc_readmem ( struct thread *  td,
struct proc *  p,
vm_offset_t  va,
void *  buf,
size_t  len 
)

Definition at line 444 of file sys_process.c.

References buf, and proc_iop().

Referenced by get_proc_vector(), kern_ptrace(), and proc_read_string().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_rwmem()

int proc_rwmem ( struct proc *  p,
struct uio *  uio 
)

Definition at line 331 of file sys_process.c.

Referenced by kern_ptrace(), and proc_iop().

Here is the caller graph for this function:

◆ proc_set_traced()

void proc_set_traced ( struct proc *  p,
bool  stop 
)

Definition at line 734 of file sys_process.c.

References proctree_lock, and stop.

Referenced by do_fork(), and kern_ptrace().

Here is the caller graph for this function:

◆ proc_sstep()

int proc_sstep ( struct thread *  td)

Definition at line 324 of file sys_process.c.

References PROC_ACTION.

◆ proc_write_dbregs()

int proc_write_dbregs ( struct thread *  td,
struct dbreg *  dbregs 
)

Definition at line 135 of file sys_process.c.

References PROC_ACTION.

◆ proc_write_fpregs()

int proc_write_fpregs ( struct thread *  td,
struct fpreg *  fpregs 
)

Definition at line 153 of file sys_process.c.

References PROC_ACTION.

◆ proc_write_regs()

int proc_write_regs ( struct thread *  td,
struct reg *  regs 
)

Definition at line 121 of file sys_process.c.

References PROC_ACTION.

◆ proc_write_regset()

static int proc_write_regset ( struct thread *  td,
int  note,
struct iovec *  iov 
)
static

Definition at line 238 of file sys_process.c.

References buf, free(), malloc(), PROC_ASSERT_TRACEREQ, and proc_find_regset().

Referenced by kern_ptrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ proc_writemem()

ssize_t proc_writemem ( struct thread *  td,
struct proc *  p,
vm_offset_t  va,
void *  buf,
size_t  len 
)

Definition at line 452 of file sys_process.c.

References buf, and proc_iop().

Referenced by kern_ptrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ptrace_sel_coredump_thread()

static struct thread * ptrace_sel_coredump_thread ( struct proc *  p)
static

Definition at line 791 of file sys_process.c.

Referenced by kern_ptrace().

Here is the caller graph for this function:

◆ ptrace_unsuspend()

void ptrace_unsuspend ( struct proc *  p)

Definition at line 746 of file sys_process.c.

References itimer_proc_continue(), kqtimer_proc_continue(), and thread_unsuspend().

Referenced by exit1(), and kern_ptrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ptrace_vm_entry()

static int ptrace_vm_entry ( struct thread *  td,
struct proc *  p,
struct ptrace_vm_entry *  pve 
)
static

Definition at line 460 of file sys_process.c.

References free(), vn_fullpath(), vput(), and vref().

Referenced by kern_ptrace(), and sys_ptrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_ptrace()

int sys_ptrace ( struct thread *  td,
struct ptrace_args uap 
)

Definition at line 584 of file sys_process.c.

References addr, ptrace_args::addr, allow_ptrace, ptrace_args::data, kern_ptrace(), ptrace_args::pid, ptrace_coredump(), ptrace_vm_entry(), and ptrace_args::req.

Here is the call graph for this function: