1. 29 7月, 2015 5 次提交
    • M
      powerpc: Change syscall_get_nr() to return int · e9fbe686
      Michael Ellerman 提交于
      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: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      e9fbe686
    • M
      powerpc: Use orig_gpr3 in syscall_get_arguments() · 1cb9839b
      Michael Ellerman 提交于
      Currently syscall_get_arguments() is used by syscall tracepoints, and
      collect_syscall() which is used in some debugging as well as
      /proc/pid/syscall.
      
      The current implementation just copies regs->gpr[3 .. 5] out, which is
      fine for all the current use cases.
      
      When we enable seccomp filter, that will also start using
      syscall_get_arguments(). However for seccomp filter we want to use r3
      as the return value of the syscall, and orig_gpr3 as the first
      parameter. This will allow seccomp to modify the return value in r3.
      
      To support this we need to modify syscall_get_arguments() to return
      orig_gpr3 instead of r3. This is safe for all uses because orig_gpr3
      always contains the r3 value that was passed to the syscall. We store it
      in the syscall entry path and never modify it.
      
      Update syscall_set_arguments() while we're here, even though it's never
      used.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      1cb9839b
    • M
      powerpc: Rework syscall_get_arguments() so there is only one loop · a7657844
      Michael Ellerman 提交于
      Currently syscall_get_arguments() has two loops, one for compat and one
      for regular tasks. In prepartion for the next patch, which changes which
      registers we use, switch it to only have one loop, so we only have one
      place to update.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      a7657844
    • M
      powerpc: Don't negate error in syscall_set_return_value() · 1b1a3702
      Michael Ellerman 提交于
      Currently the only caller of syscall_set_return_value() is seccomp
      filter, which is not enabled on powerpc.
      
      This means we have not noticed that our implementation of
      syscall_set_return_value() negates error, even though the value passed
      in is already negative.
      
      So remove the negation in syscall_set_return_value(), and expect the
      caller to do it like all other implementations do.
      
      Also add a comment about the ccr handling.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      1b1a3702
    • M
      powerpc: Drop unused syscall_get_error() · 2923e6d5
      Michael Ellerman 提交于
      syscall_get_error() is unused, and never has been.
      
      It's also probably wrong, as it negates r3 before returning it, but that
      depends on what the caller is expecting.
      
      It also doesn't deal with compat, and doesn't deal with TIF_NOERROR.
      
      Although we could fix those, until it has a caller and it's clear what
      semantics the caller wants it's just untested code. So drop it.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      2923e6d5
  2. 12 12月, 2014 1 次提交
  3. 10 10月, 2014 1 次提交
    • R
      powerpc: Fix sys_call_table declaration to enable syscall tracing · 1028ccf5
      Romeo Cane 提交于
      Declaring sys_call_table as a pointer causes the compiler to generate
      the wrong lookup code in arch_syscall_addr().
      
           <arch_syscall_addr>:
              lis     r9,-16384
              rlwinm  r3,r3,2,0,29
        -     lwz     r11,30640(r9)
        -     lwzx    r3,r11,r3
        +     addi    r9,r9,30640
        +     lwzx    r3,r9,r3
              blr
      
      The actual sys_call_table symbol, declared in assembler, is an
      array. If we lie about that to the compiler we get the wrong code
      generated, as above.
      
      This definition seems only to be used by the syscall tracing code in
      kernel/trace/trace_syscalls.c. With this patch I can successfully use
      the syscall tracepoints:
      
        bash-3815  [002] ....   333.239082: sys_write -> 0x2
        bash-3815  [002] ....   333.239087: sys_dup2(oldfd: a, newfd: 1)
        bash-3815  [002] ....   333.239088: sys_dup2 -> 0x1
        bash-3815  [002] ....   333.239092: sys_fcntl(fd: a, cmd: 1, arg: 0)
        bash-3815  [002] ....   333.239093: sys_fcntl -> 0x1
        bash-3815  [002] ....   333.239094: sys_close(fd: a)
        bash-3815  [002] ....   333.239094: sys_close -> 0x0
      Signed-off-by: NRomeo Cane <romeo.cane.ext@coriant.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      1028ccf5
  4. 24 9月, 2014 2 次提交
  5. 26 5月, 2011 1 次提交
    • I
      powerpc/ftrace: Implement raw syscall tracepoints on PowerPC · 02424d89
      Ian Munsie 提交于
      This patch implements the raw syscall tracepoints on PowerPC and exports
      them for ftrace syscalls to use.
      
      To minimise reworking existing code, I slightly re-ordered the thread
      info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
      within the 16 bits of the andi. instruction's UI field. The instructions
      in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
      _TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
      is enabled.
      
      In the case of 64bit PowerPC, arch_syscall_addr and
      arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
      work given the unusual system call table structure and symbol names that
      start with a period.
      Signed-off-by: NIan Munsie <imunsie@au1.ibm.com>
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      02424d89
  6. 19 3月, 2010 1 次提交
  7. 04 8月, 2008 1 次提交
  8. 28 7月, 2008 1 次提交