Restore the "trivial" EXEC/EXIT/CLONE utrace hooks. Add the
simple helper, UTRACE_HOOK(), to minimize the changes.
Signed-off-by: Oleg Nesterov <oleg(a)redhat.com>
---
fs/exec.c | 5 ++++-
include/linux/utrace.h | 6 ++++++
kernel/exit.c | 1 +
kernel/fork.c | 4 ++++
4 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index da80612..a0814cd 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1401,9 +1401,12 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs
*regs)
*/
bprm->recursion_depth = depth;
if (retval >= 0) {
- if (depth == 0)
+ if (depth == 0) {
+ UTRACE_HOOK(current, EXEC,
+ report_exec(fmt, bprm, regs));
ptrace_event(PTRACE_EVENT_EXEC,
old_pid);
+ }
put_binfmt(fmt);
allow_write_access(bprm->file);
if (bprm->file)
diff --git a/include/linux/utrace.h b/include/linux/utrace.h
index 1b8da1c..9ac0b1b 100644
--- a/include/linux/utrace.h
+++ b/include/linux/utrace.h
@@ -109,6 +109,12 @@ void utrace_signal_handler(struct task_struct *, int);
#define UTRACE_FLAG(task, ev) (task_utrace_flags(task) & UTRACE_EVENT(ev))
+#define UTRACE_HOOK(task, ev, callback) \
+ do { \
+ if (UTRACE_FLAG(task, ev)) \
+ utrace_ ## callback; \
+ } while (0)
+
#ifndef CONFIG_UTRACE
/*
diff --git a/kernel/exit.c b/kernel/exit.c
index 2913b35..c1b0ab6 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -913,6 +913,7 @@ NORET_TYPE void do_exit(long code)
*/
set_fs(USER_DS);
+ UTRACE_HOOK(current, EXIT, report_exit(&code));
ptrace_event(PTRACE_EVENT_EXIT, code);
validate_creds_for_do_exit(tsk);
diff --git a/kernel/fork.c b/kernel/fork.c
index a9891da..37f4a07 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1539,6 +1539,8 @@ long do_fork(unsigned long clone_flags,
audit_finish_fork(p);
+ UTRACE_HOOK(current, CLONE, report_clone(clone_flags, p));
+
/*
* We set PF_STARTING at creation in case tracing wants to
* use this to distinguish a fully live task from one that
@@ -1550,6 +1552,8 @@ long do_fork(unsigned long clone_flags,
wake_up_new_task(p);
/* forking complete and child started to run, tell ptracer */
+ if (clone_flags & CLONE_VFORK)
+ UTRACE_HOOK(current, CLONE, finish_vfork(current));
if (unlikely(trace))
ptrace_event(trace, nr);
--
1.5.5.1