1. 02 3月, 2017 2 次提交
  2. 13 4月, 2015 1 次提交
  3. 13 2月, 2015 1 次提交
    • A
      all arches, signal: move restart_block to struct task_struct · f56141e3
      Andy Lutomirski 提交于
      If an attacker can cause a controlled kernel stack overflow, overwriting
      the restart block is a very juicy exploit target.  This is because the
      restart_block is held in the same memory allocation as the kernel stack.
      
      Moving the restart block to struct task_struct prevents this exploit by
      making the restart_block harder to locate.
      
      Note that there are other fields in thread_info that are also easy
      targets, at least on some architectures.
      
      It's also a decent simplification, since the restart code is more or less
      identical on all architectures.
      
      [james.hogan@imgtec.com: metag: align thread_info::supervisor_stack]
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: David Miller <davem@davemloft.net>
      Acked-by: NRichard Weinberger <richard@nod.at>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
      Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
      Cc: Steven Miao <realmz6@gmail.com>
      Cc: Mark Salter <msalter@redhat.com>
      Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Cc: Jesper Nilsson <jesper.nilsson@axis.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Richard Kuo <rkuo@codeaurora.org>
      Cc: "Luck, Tony" <tony.luck@intel.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Tested-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Chen Liqin <liqin.linux@gmail.com>
      Cc: Lennox Wu <lennox.wu@gmail.com>
      Cc: Chris Metcalf <cmetcalf@ezchip.com>
      Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f56141e3
  4. 12 11月, 2014 1 次提交
  5. 04 11月, 2014 1 次提交
    • C
      arch: tile: kernel: signal.c: Use __copy_from/to_user() instead of __get/put_user() · 01f7ae05
      Chen Gang 提交于
      setup/restore_sigcontext() want to copy all related registers between
      user and kernel. So use block copy instead of each registers copy. Then
      can let code simple and clearer (which can avoid compiler's warning):
      
      The related warning (with allmodconfig under tile):
      
          CC      arch/tile/kernel/signal.o
        In file included from include/linux/poll.h:11:0,
                         from include/linux/ring_buffer.h:7,
                         from include/linux/ftrace_event.h:5,
                         from include/trace/syscall.h:6,
                         from include/linux/syscalls.h:81,
                         from arch/tile/kernel/signal.c:30:
        arch/tile/kernel/signal.c: In function 'setup_sigcontext':
        arch/tile/kernel/signal.c:116:31: warning: iteration 53u invokes undefined behavior [-Waggressive-loop-optimizations]
           err |= __put_user(regs->regs[i], &sc->gregs[i]);
                                       ^
        ./arch/tile/include/asm/uaccess.h:236:26: note: in definition of macro '__put_user_asm'
                : "r" (ptr), "r" (x), "i" (-EFAULT))
                                  ^
        ./arch/tile/include/asm/uaccess.h:297:10: note: in expansion of macro '__put_user_8'
          case 8: __put_user_8(x, ptr, __ret); break;   \
                  ^
        arch/tile/kernel/signal.c:116:10: note: in expansion of macro '__put_user'
           err |= __put_user(regs->regs[i], &sc->gregs[i]);
                  ^
        arch/tile/kernel/signal.c:115:2: note: containing loop
          for (i = 0; i < sizeof(struct pt_regs)/sizeof(long); ++i)
          ^
      Signed-off-by: NChen Gang <gang.chen.5i5j@gmail.com>
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      01f7ae05
  6. 06 8月, 2014 1 次提交
  7. 29 5月, 2014 1 次提交
  8. 14 8月, 2013 1 次提交
    • C
      tile: implement gettimeofday() via vDSO · 4a556f4f
      Chris Metcalf 提交于
      This change creates the framework for vDSO calls, makes the existing
      rt_sigreturn() mechanism use it, and adds a fast gettimeofday().
      Now that we need to expose the vDSO address to userspace, we add
      AT_SYSINFO_EHDR to the set of aux entries provided to userspace.
      (You can disable any extra vDSO support by booting with vdso=0,
      but the rt_sigreturn vDSO page will still be provided.)
      
      Note that glibc has supported the tile vDSO since release 2.17.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      4a556f4f
  9. 04 2月, 2013 1 次提交
  10. 24 10月, 2012 1 次提交
    • C
      arch/tile: eliminate pt_regs trampolines for syscalls · 6b14e419
      Chris Metcalf 提交于
      Using the new current_pt_regs() model, we can remove some trampolines
      from assembly code and call directly to the C syscall implementations.
      rt_sigreturn() and clone() still need some assembly wrapping, but no
      longer are passed a pt_regs pointer.  sigaltstack() and the
      tilepro-specific cmpxchg_badaddr() syscalls are now just straight C.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      6b14e419
  11. 01 10月, 2012 1 次提交
  12. 02 6月, 2012 5 次提交
  13. 14 3月, 2012 1 次提交
    • M
      tile: Use set_current_blocked() and block_sigmask() · ad092338
      Matt Fleming 提交于
      As described in e6fa16ab ("signal: sigprocmask() should do
      retarget_shared_pending()") the modification of current->blocked is
      incorrect as we need to check whether the signal we're about to block
      is pending in the shared queue.
      
      Also, use the new helper function introduced in commit 5e6292c0
      ("signal: add block_sigmask() for adding sigmask to current->blocked")
      which centralises the code for updating current->blocked after
      successfully delivering a signal and reduces the amount of duplicate
      code across architectures. In the past some architectures got this
      code wrong, so using this helper function should stop that from
      happening again.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Acked-by: NOleg Nesterov <oleg@redhat.com>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      ad092338
  14. 20 5月, 2011 1 次提交
    • C
      arch/tile: support signal "exception-trace" hook · 571d76ac
      Chris Metcalf 提交于
      This change adds support for /proc/sys/debug/exception-trace to tile.
      Like x86 and sparc, by default it is set to "1", generating a one-line
      printk whenever a user process crashes.  By setting it to "2", we get
      a much more complete userspace diagnostic at crash time, including
      a user-space backtrace, register dump, and memory dump around the
      address of the crash.
      
      Some vestiges of the Tilera-internal version of this support are
      removed with this patch (the show_crashinfo variable and the
      arch_coredump_signal function).  We retain a "crashinfo" boot parameter
      which allows you to set the boot-time value of exception-trace.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      571d76ac
  15. 18 12月, 2010 1 次提交
    • C
      arch/tile: handle rt_sigreturn() more cleanly · 81711cee
      Chris Metcalf 提交于
      The current tile rt_sigreturn() syscall pattern uses the common idiom
      of loading up pt_regs with all the saved registers from the time of
      the signal, then anticipating the fact that we will clobber the ABI
      "return value" register (r0) as we return from the syscall by setting
      the rt_sigreturn return value to whatever random value was in the pt_regs
      for r0.
      
      However, this breaks in our 64-bit kernel when running "compat" tasks,
      since we always sign-extend the "return value" register to properly
      handle returned pointers that are in the upper 2GB of the 32-bit compat
      address space.  Doing this to the sigreturn path then causes occasional
      random corruption of the 64-bit r0 register.
      
      Instead, we stop doing the crazy "load the return-value register"
      hack in sigreturn.  We already have some sigreturn-specific assembly
      code that we use to pass the pt_regs pointer to C code.  We extend that
      code to also set the link register to point to a spot a few instructions
      after the usual syscall return address so we don't clobber the saved r0.
      Now it no longer matters what the rt_sigreturn syscall returns, and the
      pt_regs structure can be cleanly and completely reloaded.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      81711cee
  16. 18 11月, 2010 1 次提交
  17. 02 11月, 2010 2 次提交
    • C
      arch/tile: don't allow user code to set the PL via ptrace or signal return · 1deb9c5d
      Chris Metcalf 提交于
      The kernel was allowing any component of the pt_regs to be updated either
      by signal handlers writing to the stack, or by processes writing via
      PTRACE_POKEUSR or PTRACE_SETREGS, which meant they could set their PL
      up from 0 to 1 and get access to kernel code and data (or, in practice,
      cause a kernel panic).  We now always reset the ex1 field, allowing the
      user to set their ICS bit only.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      1deb9c5d
    • C
      arch/tile: correct double syscall restart for nested signals · 34a89d26
      Chris Metcalf 提交于
      This change is modelled on similar fixes for other architectures.
      The pt_regs "faultnum" member is set to the trap (fault) number that
      caused us to enter the kernel, and is INT_SWINT_1 for the syscall software
      interrupt.  We already supported a pseudo value, INT_SWINT_1_SIGRETURN,
      that we used for the rt_sigreturn syscall; it avoided the case where
      one signal was handled, then we "tail-called" to another handler.
      
      This change avoids the similar case where we start to call one handler,
      then are preempted into another handler when we start trying to run
      the first handler.  We clear ->faultnum after calling handle_signal(),
      and to be paranoid also in the case where there was no signal to deliver.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      34a89d26
  18. 15 10月, 2010 1 次提交
    • C
      arch/tile: Use <asm-generic/syscalls.h> · d929b6ae
      Chris Metcalf 提交于
      With this change we now include <asm-generic/syscalls.h> into the "tile"
      version of the header.  To take full advantage of the prototypes there,
      we also change our naming convention for "struct pt_regs *" syscalls so
      that, e.g., _sys_execve() is the "true" syscall entry, which sets the
      appropriate register to point to the pt_regs before calling sys_execve().
      
      While doing this I realized I no longer needed the fork and vfork
      entry point stubs, since those functions aren't in the generic
      syscall ABI, so I removed them as well.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      d929b6ae
  19. 15 9月, 2010 1 次提交
    • C
      arch/tile: Change struct sigcontext to be more useful · 74fca9da
      Chris Metcalf 提交于
      Rather than just using pt_regs, it now contains the actual saved
      state explicitly, similar to pt_regs.  By doing it this way, we
      provide a cleaner API for userspace (or equivalently, we avoid the
      need for libc to provide its own definition of sigcontext).
      
      While we're at it, move PT_FLAGS_xxx to where they are not visible
      from userspace.  And always pass siginfo and mcontext to signal
      handlers, even if they claim they don't need it, since sometimes
      they actually try to use it anyway in practice.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      74fca9da
  20. 07 7月, 2010 1 次提交
    • C
      arch/tile: Miscellaneous cleanup changes. · 0707ad30
      Chris Metcalf 提交于
      This commit is primarily changes caused by reviewing "sparse"
      and "checkpatch" output on our sources, so is somewhat noisy, since
      things like "printk() -> pr_err()" (or whatever) throughout the
      codebase tend to get tedious to read.  Rather than trying to tease
      apart precisely which things changed due to which type of code
      review, this commit includes various cleanups in the code:
      
      - sparse: Add declarations in headers for globals.
      - sparse: Fix __user annotations.
      - sparse: Using gfp_t consistently instead of int.
      - sparse: removing functions not actually used.
      - checkpatch: Clean up printk() warnings by using pr_info(), etc.;
        also avoid partial-line printks except in bootup code.
        - checkpatch: Use exposed structs rather than typedefs.
        - checkpatch: Change some C99 comments to C89 comments.
      
      In addition, a couple of minor other changes are rolled in
      to this commit:
      
      - Add support for a "raise" instruction to cause SIGFPE, etc., to be raised.
      - Remove some compat code that is unnecessary when we fully eliminate
        some of the deprecated syscalls from the generic syscall ABI.
      - Update the tile_defconfig to reflect current config contents.
      Signed-off-by: NChris Metcalf <cmetcalf@tilera.com>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      0707ad30
  21. 07 6月, 2010 1 次提交
  22. 05 6月, 2010 1 次提交