aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-07-25 22:45:49 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-26 15:00:08 -0400
commit0d094efeb1e98010c6b99923f1eb7e17bf1e3a74 (patch)
tree6ee271b6da5796e5321d2ab6f9d7d9ba03c300a2 /include
parentdae33574dcf5211e1f43c7e45fa29f73ba3e00cb (diff)
tracehook: tracehook_tracer_task
This adds the tracehook_tracer_task() hook to consolidate all forms of "Who is using ptrace on me?" logic. This is used for "TracerPid:" in /proc and for permission checks. We also clean up the selinux code the called an identical accessor. Signed-off-by: Roland McGrath <roland@redhat.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Reviewed-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/tracehook.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 9a5b3be2503a..6468ca0fe69b 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -73,6 +73,24 @@ static inline int tracehook_unsafe_exec(struct task_struct *task)
73} 73}
74 74
75/** 75/**
76 * tracehook_tracer_task - return the task that is tracing the given task
77 * @tsk: task to consider
78 *
79 * Returns NULL if noone is tracing @task, or the &struct task_struct
80 * pointer to its tracer.
81 *
82 * Must called under rcu_read_lock(). The pointer returned might be kept
83 * live only by RCU. During exec, this may be called with task_lock()
84 * held on @task, still held from when tracehook_unsafe_exec() was called.
85 */
86static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk)
87{
88 if (task_ptrace(tsk) & PT_PTRACED)
89 return rcu_dereference(tsk->parent);
90 return NULL;
91}
92
93/**
76 * tracehook_report_exec - a successful exec was completed 94 * tracehook_report_exec - a successful exec was completed
77 * @fmt: &struct linux_binfmt that performed the exec 95 * @fmt: &struct linux_binfmt that performed the exec
78 * @bprm: &struct linux_binprm containing exec details 96 * @bprm: &struct linux_binprm containing exec details