• Rich Felker's avatar
    sh: fix syscall tracing · b0cfc315
    Rich Felker authored
    Addition of SECCOMP_FILTER exposed a longstanding bug in
    do_syscall_trace_enter, whereby r0 (the 5th argument register) was
    mistakenly used where r3 (syscall_nr) was intended. By overwriting r0
    rather than r3 with -1 when attempting to block a syscall, the
    existing code would instead have caused the syscall to execute with an
    argument clobbered.
    
    Commit 0bb605c2 then introduced skipping of the syscall when
    do_syscall_trace_enter returns -1, so that the return value set by
    seccomp filters would not be clobbered by -ENOSYS. This eliminated the
    clobbering of the 5th argument register, but instead caused syscalls
    made with a 5th argument of -1 to be misinterpreted as a request by
    do_syscall_trace_enter to suppress the syscall.
    
    Fixes: 0bb605c2 ("sh: Add SECCOMP_FILTER")
    Fixes: ab99c733 ("sh: Make syscall tracer use tracehook notifiers, add TIF_NOTIFY_RESUME.")
    Tested-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
    Signed-off-by: default avatarRich Felker <dalias@libc.org>
    b0cfc315
ptrace_32.c 11.4 KB