aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-07-25 22:45:44 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-26 15:00:08 -0400
commit6341c393fcc37d58727865f1ee2f65e632e9d4f0 (patch)
tree6e88d928e17f663b225884e81877a7a069d7c514 /include
parent88ac2921a71f788ed693bcd44731dd6bc1994640 (diff)
tracehook: exec
This moves all the ptrace hooks related to exec into tracehook.h inlines. This also lifts the calls for tracing out of the binfmt load_binary hooks into search_binary_handler() after it calls into the binfmt module. This change has no effect, since all the binfmt modules' load_binary functions did the call at the end on success, and now search_binary_handler() does it immediately after return if successful. We consolidate the repeated code, and binfmt modules no longer need to import ptrace_notify(). 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.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index bea0f3eeff54..6276353709c1 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -48,5 +48,51 @@
48 48
49#include <linux/sched.h> 49#include <linux/sched.h>
50#include <linux/ptrace.h> 50#include <linux/ptrace.h>
51#include <linux/security.h>
52struct linux_binprm;
53
54/**
55 * tracehook_unsafe_exec - check for exec declared unsafe due to tracing
56 * @task: current task doing exec
57 *
58 * Return %LSM_UNSAFE_* bits applied to an exec because of tracing.
59 *
60 * Called with task_lock() held on @task.
61 */
62static inline int tracehook_unsafe_exec(struct task_struct *task)
63{
64 int unsafe = 0;
65 int ptrace = task_ptrace(task);
66 if (ptrace & PT_PTRACED) {
67 if (ptrace & PT_PTRACE_CAP)
68 unsafe |= LSM_UNSAFE_PTRACE_CAP;
69 else
70 unsafe |= LSM_UNSAFE_PTRACE;
71 }
72 return unsafe;
73}
74
75/**
76 * tracehook_report_exec - a successful exec was completed
77 * @fmt: &struct linux_binfmt that performed the exec
78 * @bprm: &struct linux_binprm containing exec details
79 * @regs: user-mode register state
80 *
81 * An exec just completed, we are shortly going to return to user mode.
82 * The freshly initialized register state can be seen and changed in @regs.
83 * The name, file and other pointers in @bprm are still on hand to be
84 * inspected, but will be freed as soon as this returns.
85 *
86 * Called with no locks, but with some kernel resources held live
87 * and a reference on @fmt->module.
88 */
89static inline void tracehook_report_exec(struct linux_binfmt *fmt,
90 struct linux_binprm *bprm,
91 struct pt_regs *regs)
92{
93 if (!ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0) &&
94 unlikely(task_ptrace(current) & PT_PTRACED))
95 send_sig(SIGTRAP, current, 0);
96}
51 97
52#endif /* <linux/tracehook.h> */ 98#endif /* <linux/tracehook.h> */