Re: [PATCH 3/7] ptrace: move SIGTRAP on exec(2) logic toptrace_event()

From: Oleg Nesterov
Date: Mon Jun 20 2011 - 16:27:03 EST


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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/