Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
ptrace.h File Reference
#include <linux/compiler.h>
#include <linux/sched.h>
#include <linux/err.h>
#include <linux/bug.h>
#include <uapi/linux/ptrace.h>

Go to the source code of this file.

Macros

#define PT_SEIZED   0x00010000 /* SEIZE used, enable new behavior */
 
#define PT_PTRACED   0x00000001
 
#define PT_DTRACE   0x00000002 /* delayed trace (used on m68k, i386) */
 
#define PT_PTRACE_CAP   0x00000004 /* ptracer can follow suid-exec */
 
#define PT_OPT_FLAG_SHIFT   3
 
#define PT_EVENT_FLAG(event)   (1 << (PT_OPT_FLAG_SHIFT + (event)))
 
#define PT_TRACESYSGOOD   PT_EVENT_FLAG(0)
 
#define PT_TRACE_FORK   PT_EVENT_FLAG(PTRACE_EVENT_FORK)
 
#define PT_TRACE_VFORK   PT_EVENT_FLAG(PTRACE_EVENT_VFORK)
 
#define PT_TRACE_CLONE   PT_EVENT_FLAG(PTRACE_EVENT_CLONE)
 
#define PT_TRACE_EXEC   PT_EVENT_FLAG(PTRACE_EVENT_EXEC)
 
#define PT_TRACE_VFORK_DONE   PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE)
 
#define PT_TRACE_EXIT   PT_EVENT_FLAG(PTRACE_EVENT_EXIT)
 
#define PT_TRACE_SECCOMP   PT_EVENT_FLAG(PTRACE_EVENT_SECCOMP)
 
#define PT_SINGLESTEP_BIT   31
 
#define PT_SINGLESTEP   (1<<PT_SINGLESTEP_BIT)
 
#define PT_BLOCKSTEP_BIT   30
 
#define PT_BLOCKSTEP   (1<<PT_BLOCKSTEP_BIT)
 
#define PTRACE_MODE_READ   0x01
 
#define PTRACE_MODE_ATTACH   0x02
 
#define PTRACE_MODE_NOAUDIT   0x04
 
#define force_successful_syscall_return()   do { } while (0)
 
#define is_syscall_success(regs)   (!IS_ERR_VALUE((unsigned long)(regs_return_value(regs))))
 
#define arch_has_single_step()   (0)
 
#define arch_has_block_step()   (0)
 

Functions

long arch_ptrace (struct task_struct *child, long request, unsigned long addr, unsigned long data)
 
int ptrace_readdata (struct task_struct *tsk, unsigned long src, char __user *dst, int len)
 
int ptrace_writedata (struct task_struct *tsk, char __user *src, unsigned long dst, int len)
 
void ptrace_disable (struct task_struct *)
 
int ptrace_check_attach (struct task_struct *task, bool ignore_state)
 
int ptrace_request (struct task_struct *child, long request, unsigned long addr, unsigned long data)
 
void ptrace_notify (int exit_code)
 
void __ptrace_link (struct task_struct *child, struct task_struct *new_parent)
 
void __ptrace_unlink (struct task_struct *child)
 
void exit_ptrace (struct task_struct *tracer)
 
bool ptrace_may_access (struct task_struct *task, unsigned int mode)
 
int generic_ptrace_peekdata (struct task_struct *tsk, unsigned long addr, unsigned long data)
 
int generic_ptrace_pokedata (struct task_struct *tsk, unsigned long addr, unsigned long data)
 

Macro Definition Documentation

#define arch_has_block_step ( )    (0)

arch_has_block_step - does this CPU support user-mode block-step?

If this is defined, then there must be a function declaration or inline for user_enable_block_step(), and arch_has_single_step() must be defined too. arch_has_block_step() should evaluate to nonzero iff the machine supports step-until-branch for user mode. It can be a constant or it can test a CPU feature bit.

Definition at line 262 of file ptrace.h.

#define arch_has_single_step ( )    (0)

arch_has_single_step - does this CPU support user-mode single-step?

If this is defined, then there must be function declarations or inlines for user_enable_single_step() and user_disable_single_step(). arch_has_single_step() should evaluate to nonzero iff the machine supports instruction single-step for user mode. It can be a constant or it can test a CPU feature bit.

Definition at line 219 of file ptrace.h.

#define force_successful_syscall_return ( )    do { } while (0)

Definition at line 189 of file ptrace.h.

#define is_syscall_success (   regs)    (!IS_ERR_VALUE((unsigned long)(regs_return_value(regs))))

Definition at line 198 of file ptrace.h.

#define PT_BLOCKSTEP   (1<<PT_BLOCKSTEP_BIT)

Definition at line 39 of file ptrace.h.

#define PT_BLOCKSTEP_BIT   30

Definition at line 38 of file ptrace.h.

#define PT_DTRACE   0x00000002 /* delayed trace (used on m68k, i386) */

Definition at line 20 of file ptrace.h.

#define PT_EVENT_FLAG (   event)    (1 << (PT_OPT_FLAG_SHIFT + (event)))

Definition at line 25 of file ptrace.h.

#define PT_OPT_FLAG_SHIFT   3

Definition at line 23 of file ptrace.h.

#define PT_PTRACE_CAP   0x00000004 /* ptracer can follow suid-exec */

Definition at line 21 of file ptrace.h.

#define PT_PTRACED   0x00000001

Definition at line 19 of file ptrace.h.

#define PT_SEIZED   0x00010000 /* SEIZE used, enable new behavior */

Definition at line 18 of file ptrace.h.

#define PT_SINGLESTEP   (1<<PT_SINGLESTEP_BIT)

Definition at line 37 of file ptrace.h.

#define PT_SINGLESTEP_BIT   31

Definition at line 36 of file ptrace.h.

#define PT_TRACE_CLONE   PT_EVENT_FLAG(PTRACE_EVENT_CLONE)

Definition at line 29 of file ptrace.h.

#define PT_TRACE_EXEC   PT_EVENT_FLAG(PTRACE_EVENT_EXEC)

Definition at line 30 of file ptrace.h.

#define PT_TRACE_EXIT   PT_EVENT_FLAG(PTRACE_EVENT_EXIT)

Definition at line 32 of file ptrace.h.

#define PT_TRACE_FORK   PT_EVENT_FLAG(PTRACE_EVENT_FORK)

Definition at line 27 of file ptrace.h.

#define PT_TRACE_SECCOMP   PT_EVENT_FLAG(PTRACE_EVENT_SECCOMP)

Definition at line 33 of file ptrace.h.

#define PT_TRACE_VFORK   PT_EVENT_FLAG(PTRACE_EVENT_VFORK)

Definition at line 28 of file ptrace.h.

#define PT_TRACE_VFORK_DONE   PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE)

Definition at line 31 of file ptrace.h.

#define PT_TRACESYSGOOD   PT_EVENT_FLAG(0)

Definition at line 26 of file ptrace.h.

#define PTRACE_MODE_ATTACH   0x02

Definition at line 55 of file ptrace.h.

#define PTRACE_MODE_NOAUDIT   0x04

Definition at line 56 of file ptrace.h.

#define PTRACE_MODE_READ   0x01

Definition at line 54 of file ptrace.h.

Function Documentation

void __ptrace_link ( struct task_struct child,
struct task_struct new_parent 
)

Definition at line 41 of file ptrace.c.

void __ptrace_unlink ( struct task_struct child)

__ptrace_unlink - unlink ptracee and restore its execution state : ptracee to be unlinked

Remove from the ptrace list, move it back to the original parent, and restore the execution state so that it conforms to the group stop state.

Unlinking can happen via two paths - explicit PTRACE_DETACH or ptracer exiting. For PTRACE_DETACH, unless the ptracee has been killed between ptrace_check_attach() and here, it's guaranteed to be in TASK_TRACED. If the ptracer is exiting, the ptracee can be in any state.

After detach, the ptracee should be in a state which conforms to the group stop. If the group is stopped or in the process of stopping, the ptracee should be put into TASK_STOPPED; otherwise, it should be woken up from TASK_TRACED.

If the ptracee is in TASK_TRACED and needs to be moved to TASK_STOPPED, it goes through TRACED -> RUNNING -> STOPPED transition which is similar to but in the opposite direction of what happens while attaching to a stopped task. However, in this direction, the intermediate RUNNING state is not hidden even from the current ptracer and if it immediately re-attaches and performs a WNOHANG wait(2), it may fail.

CONTEXT: write_lock_irq(tasklist_lock)

Definition at line 76 of file ptrace.c.

long arch_ptrace ( struct task_struct child,
long  request,
unsigned long  addr,
unsigned long  data 
)

Definition at line 272 of file ptrace.c.

void exit_ptrace ( struct task_struct tracer)

Definition at line 449 of file ptrace.c.

int generic_ptrace_peekdata ( struct task_struct tsk,
unsigned long  addr,
unsigned long  data 
)

Definition at line 901 of file ptrace.c.

int generic_ptrace_pokedata ( struct task_struct tsk,
unsigned long  addr,
unsigned long  data 
)

Definition at line 913 of file ptrace.c.

int ptrace_check_attach ( struct task_struct child,
bool  ignore_state 
)

ptrace_check_attach - check whether ptracee is ready for ptrace operation : ptracee to check for : don't check whether is currently TASK_TRACED

Check whether is being ptraced by current and ready for further ptrace operations. If is false, also should be in TASK_TRACED state and on return the child is guaranteed to be traced and not executing. If is true, can be in any state.

CONTEXT: Grabs and releases tasklist_lock and ->sighand->siglock.

RETURNS: 0 on success, -ESRCH if child is not ready.

Definition at line 142 of file ptrace.c.

void ptrace_disable ( struct task_struct )

Definition at line 267 of file ptrace.c.

bool ptrace_may_access ( struct task_struct task,
unsigned int  mode 
)

Definition at line 224 of file ptrace.c.

void ptrace_notify ( int  exit_code)

Definition at line 1972 of file signal.c.

int ptrace_readdata ( struct task_struct tsk,
unsigned long  src,
char __user dst,
int  len 
)

Definition at line 475 of file ptrace.c.

int ptrace_request ( struct task_struct child,
long  request,
unsigned long  addr,
unsigned long  data 
)

Definition at line 669 of file ptrace.c.

int ptrace_writedata ( struct task_struct tsk,
char __user src,
unsigned long  dst,
int  len 
)

Definition at line 500 of file ptrace.c.