diff options
-rw-r--r-- | include/linux/tracehook.h | 15 | ||||
-rw-r--r-- | kernel/exit.c | 6 |
2 files changed, 17 insertions, 4 deletions
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 6276353709c1..967ab473afbc 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h | |||
@@ -95,4 +95,19 @@ static inline void tracehook_report_exec(struct linux_binfmt *fmt, | |||
95 | send_sig(SIGTRAP, current, 0); | 95 | send_sig(SIGTRAP, current, 0); |
96 | } | 96 | } |
97 | 97 | ||
98 | /** | ||
99 | * tracehook_report_exit - task has begun to exit | ||
100 | * @exit_code: pointer to value destined for @current->exit_code | ||
101 | * | ||
102 | * @exit_code points to the value passed to do_exit(), which tracing | ||
103 | * might change here. This is almost the first thing in do_exit(), | ||
104 | * before freeing any resources or setting the %PF_EXITING flag. | ||
105 | * | ||
106 | * Called with no locks held. | ||
107 | */ | ||
108 | static inline void tracehook_report_exit(long *exit_code) | ||
109 | { | ||
110 | ptrace_event(PT_TRACE_EXIT, PTRACE_EVENT_EXIT, *exit_code); | ||
111 | } | ||
112 | |||
98 | #endif /* <linux/tracehook.h> */ | 113 | #endif /* <linux/tracehook.h> */ |
diff --git a/kernel/exit.c b/kernel/exit.c index ad933bb29ec7..c3691cbc220a 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/resource.h> | 46 | #include <linux/resource.h> |
47 | #include <linux/blkdev.h> | 47 | #include <linux/blkdev.h> |
48 | #include <linux/task_io_accounting_ops.h> | 48 | #include <linux/task_io_accounting_ops.h> |
49 | #include <linux/tracehook.h> | ||
49 | 50 | ||
50 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
51 | #include <asm/unistd.h> | 52 | #include <asm/unistd.h> |
@@ -1029,10 +1030,7 @@ NORET_TYPE void do_exit(long code) | |||
1029 | if (unlikely(!tsk->pid)) | 1030 | if (unlikely(!tsk->pid)) |
1030 | panic("Attempted to kill the idle task!"); | 1031 | panic("Attempted to kill the idle task!"); |
1031 | 1032 | ||
1032 | if (unlikely(current->ptrace & PT_TRACE_EXIT)) { | 1033 | tracehook_report_exit(&code); |
1033 | current->ptrace_message = code; | ||
1034 | ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP); | ||
1035 | } | ||
1036 | 1034 | ||
1037 | /* | 1035 | /* |
1038 | * We're taking recursive faults here in do_exit. Safest is to just | 1036 | * We're taking recursive faults here in do_exit. Safest is to just |