diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/tracehook.h | 18 |
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) } /** + * tracehook_tracer_task - return the task that is tracing the given task + * @tsk: task to consider + * + * Returns NULL if noone is tracing @task, or the &struct task_struct + * pointer to its tracer. + * + * Must called under rcu_read_lock(). The pointer returned might be kept + * live only by RCU. During exec, this may be called with task_lock() + * held on @task, still held from when tracehook_unsafe_exec() was called. + */ +static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk) +{ + if (task_ptrace(tsk) & PT_PTRACED) + return rcu_dereference(tsk->parent); + return NULL; +} + +/** * tracehook_report_exec - a successful exec was completed * @fmt: &struct linux_binfmt that performed the exec * @bprm: &struct linux_binprm containing exec details |