• Michael Ellerman's avatar
    powerpc: Change syscall_get_nr() to return int · e9fbe686
    Michael Ellerman authored
    The documentation for syscall_get_nr() in asm-generic says:
    
     Note this returns int even on 64-bit machines. Only 32 bits of
     system call number can be meaningful. If the actual arch value
     is 64 bits, this truncates to 32 bits so 0xffffffff means -1.
    
    However our implementation was never updated to reflect this.
    
    Generally it's not important, but there is once case where it matters.
    
    For seccomp filter with SECCOMP_RET_TRACE, the tracer will set
    regs->gpr[0] to -1 to reject the syscall. When the task is a compat
    task, this means we end up with 0xffffffff in r0 because ptrace will
    zero extend the 32-bit value.
    
    If syscall_get_nr() returns an unsigned long, then a 64-bit kernel will
    see a positive value in r0 and will incorrectly allow the syscall
    through seccomp.
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Reviewed-by: default avatarKees Cook <keescook@chromium.org>
    e9fbe686
syscall.h 2.8 KB