1. 28 Feb, 2013 38 commits
  2. 27 Feb, 2013 2 commits
    • Linus Torvalds's avatar
      sysrq: don't depend on weak undefined arrays to have an address that compares as NULL · adf96e6f
      Linus Torvalds authored
      When taking an address of an extern array, gcc quite naturally should be
      able to say "an address of an object can never be NULL" and just
      optimize away the test entirely.
      
      However, the new alternate sysrq reset code (commit 154b7a48:
      "Input: sysrq - allow specifying alternate reset sequence") did exactly
      that, and declared platform_sysrq_reset_seq[] as a weak array, and
      expecting that testing the address of the array would show whether it
      actually got linked against something or not.
      
      And that doesn't work with all gcc versions.  Clearly it works with
      *some* versions of gcc, and maybe it's even supposed to work, but it
      really is a very fragile concept.
      
      So instead of testing the address of the weak variable, just create a
      weak instance of that array that is empty.  If some platform then has a
      real platform_sysrq_reset_seq[] that overrides our weak one, the linker
      will switch to that one, and it all works without any run-time
      conditionals at all.
      Reported-by: default avatarDave Airlie <airlied@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Russell King <rmk+kernel@arm.linux.org.uk>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Acked-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      adf96e6f
    • Linus Torvalds's avatar
      mm: do not grow the stack vma just because of an overrun on preceding vma · 09884964
      Linus Torvalds authored
      The stack vma is designed to grow automatically (marked with VM_GROWSUP
      or VM_GROWSDOWN depending on architecture) when an access is made beyond
      the existing boundary.  However, particularly if you have not limited
      your stack at all ("ulimit -s unlimited"), this can cause the stack to
      grow even if the access was really just one past *another* segment.
      
      And that's wrong, especially since we first grow the segment, but then
      immediately later enforce the stack guard page on the last page of the
      segment.  So _despite_ first growing the stack segment as a result of
      the access, the kernel will then make the access cause a SIGSEGV anyway!
      
      So do the same logic as the guard page check does, and consider an
      access to within one page of the next segment to be a bad access, rather
      than growing the stack to abut the next segment.
      Reported-and-tested-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      09884964