Commit f3c04b93 authored by Tejun Heo's avatar Tejun Heo Committed by Oleg Nesterov

ptrace: move SIGTRAP on exec(2) logic to ptrace_event()

Move SIGTRAP on exec(2) logic from tracehook_report_exec() to
ptrace_event().  This is part of changes to make ptrace_event()
smarter and handle ptrace event related details in one place.

This doesn't introduce any behavior change.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
parent 643ad838
...@@ -172,17 +172,17 @@ static inline bool ptrace_event_enabled(struct task_struct *task, int event) ...@@ -172,17 +172,17 @@ static inline bool ptrace_event_enabled(struct task_struct *task, int event)
* Check whether @event is enabled and, if so, report @event and @message * Check whether @event is enabled and, if so, report @event and @message
* to the ptrace parent. * to the ptrace parent.
* *
* Returns nonzero if we did a ptrace notification, zero if not.
*
* Called without locks. * Called without locks.
*/ */
static inline int ptrace_event(int event, unsigned long message) static inline void ptrace_event(int event, unsigned long message)
{ {
if (likely(!ptrace_event_enabled(current, event))) if (unlikely(ptrace_event_enabled(current, event))) {
return false;
current->ptrace_message = message; current->ptrace_message = message;
ptrace_notify((event << 8) | SIGTRAP); ptrace_notify((event << 8) | SIGTRAP);
return true; } else if (event == PTRACE_EVENT_EXEC && unlikely(current->ptrace)) {
/* legacy EXEC report via SIGTRAP */
send_sig(SIGTRAP, current, 0);
}
} }
/** /**
......
...@@ -201,9 +201,7 @@ static inline void tracehook_report_exec(struct linux_binfmt *fmt, ...@@ -201,9 +201,7 @@ static inline void tracehook_report_exec(struct linux_binfmt *fmt,
struct linux_binprm *bprm, struct linux_binprm *bprm,
struct pt_regs *regs) struct pt_regs *regs)
{ {
if (!ptrace_event(PTRACE_EVENT_EXEC, 0) && ptrace_event(PTRACE_EVENT_EXEC, 0);
unlikely(current->ptrace & PT_PTRACED))
send_sig(SIGTRAP, current, 0);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment