x86, ptrace, seccomp: Rearrange the phase1/phase2 entry split

We used to have a somewhat complex division of labor between phase1
and phase2.  It wasn't so bad, except that it committed us to running
seccomp before ptrace.

This reworks the code so that the syscall_trace_enter_phase1 is more
of a pure fast path -- it either handles everything except a
possible seccomp phase 2 or it defers everything except user_exit to
syscall_trace_enter_phase2.

This fixes a buglet: strace would see syscall -1 for that resulted
in SECCOMP_RET_ERRNO.

This should have no other effect other than changing the auditing
behavior of skipped syscalls a bit.  It was, and still is, a bit
screwed up.

As an aside: this would be vastly simplified if there were a way
to set up the slow path ptraceable registers in C.  Oh, well.

Signed-off-by: Andy Lutomirski <luto@amacapital.net>
1 file changed