Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
ptrace.c File Reference
#include <linux/capability.h>
#include <linux/export.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/mm.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/ptrace.h>
#include <linux/security.h>
#include <linux/signal.h>
#include <linux/audit.h>
#include <linux/pid_namespace.h>
#include <linux/syscalls.h>
#include <linux/uaccess.h>
#include <linux/regset.h>
#include <linux/hw_breakpoint.h>
#include <linux/cn_proc.h>

Go to the source code of this file.

Macros

#define is_singlestep(request)   0
 
#define is_singleblock(request)   0
 
#define is_sysemu_singlestep(request)   0
 
#define arch_ptrace_attach(child)   do { } while (0)
 

Functions

void __ptrace_link (struct task_struct *child, struct task_struct *new_parent)
 
void __ptrace_unlink (struct task_struct *child)
 
int ptrace_check_attach (struct task_struct *child, bool ignore_state)
 
bool ptrace_may_access (struct task_struct *task, unsigned int mode)
 
void exit_ptrace (struct task_struct *tracer) __releases(&tasklist_lock) __acquires(&tasklist_lock)
 
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)
 
int ptrace_request (struct task_struct *child, long request, unsigned long addr, unsigned long data)
 
 SYSCALL_DEFINE4 (ptrace, long, request, long, pid, unsigned long, addr, unsigned long, data)
 
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_ptrace_attach (   child)    do { } while (0)

Definition at line 855 of file ptrace.c.

#define is_singleblock (   request)    0

Definition at line 583 of file ptrace.c.

#define is_singlestep (   request)    0

Definition at line 577 of file ptrace.c.

#define is_sysemu_singlestep (   request)    0

Definition at line 589 of file ptrace.c.

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.

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.

bool ptrace_may_access ( struct task_struct task,
unsigned int  mode 
)

Definition at line 224 of file ptrace.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.

SYSCALL_DEFINE4 ( ptrace  ,
long  ,
request  ,
long  ,
pid  ,
unsigned  long,
addr  ,
unsigned  long,
data   
)

Definition at line 858 of file ptrace.c.