Messages in this thread | | | Date | Mon, 20 Jun 2011 22:25:04 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH 3/7] ptrace: move SIGTRAP on exec(2) logic to ptrace_event() |
| |
On 06/17, Tejun Heo wrote: > > 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.
I am going to apply all patches except 6/7, but to be honest this one looks a bit ugly to me.
> -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))) > - return false; > - current->ptrace_message = message; > - ptrace_notify((event << 8) | SIGTRAP); > - return true; > + if (unlikely(ptrace_event_enabled(current, event))) { > + current->ptrace_message = message; > + ptrace_notify((event << 8) | SIGTRAP); > + } else if (event == PTRACE_EVENT_EXEC && unlikely(current->ptrace)) { > + /* legacy EXEC report via SIGTRAP */ > + send_sig(SIGTRAP, current, 0); > + }
Why does this make ptrace_event() smarter?
OK, tracehooks should die. But why should we move this special case into ptrace_event? Say, a simple
static inline void ptrace_exec_event(...) { if (!ptrace_event_enabled(PTRACE_EVENT_EXEC)) send_sig(SIGTRAP, current, 0); else ptrace_event(PTRACE_EVENT_EXEC); }
in fs/exec.c looks a bit better to me.
Oleg.
| |