1. 01 Aug, 2014 3 commits
    • Alex Smith's avatar
      MIPS: ptrace: Fix user pt_regs definition, use in ptrace_{get, set}regs() · a79ebea6
      Alex Smith authored
      In uapi/asm/ptrace.h, a user version of pt_regs is defined wrapped in
      ifndef __KERNEL__. This structure definition does not match anything
      used by any kernel API, in particular it does not match the format used
      by PTRACE_{GET,SET}REGS.
      
      Therefore, replace the structure definition with one matching what is
      used by PTRACE_{GET,SET}REGS. The format used by these is the same for
      both 32-bit and 64-bit.
      
      Also, change the implementation of PTRACE_{GET,SET}REGS to use this new
      structure definition. The structure is renamed to user_pt_regs when
      __KERNEL__ is defined to avoid conflicts with the kernel's own pt_regs.
      Signed-off-by: default avatarAlex Smith <alex@alex-smith.me.uk>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/7457/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      a79ebea6
    • Alex Smith's avatar
      MIPS: O32/32-bit: Remove outdated comment · 457ed770
      Alex Smith authored
      A comment in the O32/32-bit system call code is incorrect since commit
      46e12c07 ("MIPS: O32 / 32-bit: Always copy 4 stack arguments.").
      Remove it.
      Signed-off-by: default avatarAlex Smith <alex@alex-smith.me.uk>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/7455/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      457ed770
    • Alex Smith's avatar
      MIPS: O32/32-bit: Fix bug which can cause incorrect system call restarts · e90e6fdd
      Alex Smith authored
      On 32-bit/O32, pt_regs has a padding area at the beginning into which the
      syscall arguments passed via the user stack are copied. 4 arguments
      totalling 16 bytes are copied to offset 16 bytes into this area, however
      the area is only 24 bytes long. This means the last 2 arguments overwrite
      pt_regs->regs[{0,1}].
      
      If a syscall function returns an error, handle_sys stores the original
      syscall number in pt_regs->regs[0] for syscall restart. signal.c checks
      whether regs[0] is non-zero, if it is it will check whether the syscall
      return value is one of the ERESTART* codes to see if it must be
      restarted.
      
      Should a syscall be made that results in a non-zero value being copied
      off the user stack into regs[0], and then returns a positive (non-error)
      value that matches one of the ERESTART* error codes, this can be mistaken
      for requiring a syscall restart.
      
      While the possibility for this to occur has always existed, it is made
      much more likely to occur by commit 46e12c07 ("MIPS: O32 / 32-bit:
      Always copy 4 stack arguments."), since now every syscall will copy 4
      arguments and overwrite regs[0], rather than just those with 7 or 8
      arguments.
      
      Since that commit, booting Debian under a 32-bit MIPS kernel almost
      always results in a hang early in boot, due to a wait4 syscall returning
      a PID that matches one of the ERESTART* codes, which then causes an
      incorrect restart of the syscall.
      
      The problem is fixed by increasing the size of the padding area so that
      arguments copied off the stack will not overwrite pt_regs->regs[{0,1}].
      Signed-off-by: default avatarAlex Smith <alex.smith@imgtec.com>
      Cc: <stable@vger.kernel.org> # v3.13+
      Reviewed-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      Tested-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/7454/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      e90e6fdd
  2. 30 Jul, 2014 37 commits