aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ptrace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ptrace.h')
-rw-r--r--include/linux/ptrace.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 07d0df6bf768..077904c8b70d 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -5,6 +5,7 @@
5#include <linux/sched.h> /* For struct task_struct. */ 5#include <linux/sched.h> /* For struct task_struct. */
6#include <linux/err.h> /* for IS_ERR_VALUE */ 6#include <linux/err.h> /* for IS_ERR_VALUE */
7#include <linux/bug.h> /* For BUG_ON. */ 7#include <linux/bug.h> /* For BUG_ON. */
8#include <linux/pid_namespace.h> /* For task_active_pid_ns. */
8#include <uapi/linux/ptrace.h> 9#include <uapi/linux/ptrace.h>
9 10
10/* 11/*
@@ -129,6 +130,37 @@ static inline void ptrace_event(int event, unsigned long message)
129} 130}
130 131
131/** 132/**
133 * ptrace_event_pid - possibly stop for a ptrace event notification
134 * @event: %PTRACE_EVENT_* value to report
135 * @pid: process identifier for %PTRACE_GETEVENTMSG to return
136 *
137 * Check whether @event is enabled and, if so, report @event and @pid
138 * to the ptrace parent. @pid is reported as the pid_t seen from the
139 * the ptrace parent's pid namespace.
140 *
141 * Called without locks.
142 */
143static inline void ptrace_event_pid(int event, struct pid *pid)
144{
145 /*
146 * FIXME: There's a potential race if a ptracer in a different pid
147 * namespace than parent attaches between computing message below and
148 * when we acquire tasklist_lock in ptrace_stop(). If this happens,
149 * the ptracer will get a bogus pid from PTRACE_GETEVENTMSG.
150 */
151 unsigned long message = 0;
152 struct pid_namespace *ns;
153
154 rcu_read_lock();
155 ns = task_active_pid_ns(rcu_dereference(current->parent));
156 if (ns)
157 message = pid_nr_ns(pid, ns);
158 rcu_read_unlock();
159
160 ptrace_event(event, message);
161}
162
163/**
132 * ptrace_init_task - initialize ptrace state for a new child 164 * ptrace_init_task - initialize ptrace state for a new child
133 * @child: new child task 165 * @child: new child task
134 * @ptrace: true if child should be ptrace'd by parent's tracer 166 * @ptrace: true if child should be ptrace'd by parent's tracer