aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2013-12-15 23:12:43 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-12-29 22:02:28 -0500
commit90ff5d688e61f49f23545ffab6228bd7e87e6dc7 (patch)
tree8d1788a6a1b88190379926ce726bc6867ad98dd2
parent803c2d2f84da9dc2619449994af34d27148ab20d (diff)
powerpc: Fix bad stack check in exception entry
In EXCEPTION_PROLOG_COMMON() we check to see if the stack pointer (r1) is valid when coming from the kernel. If it's not valid, we die but with a nice oops message. Currently we allocate a stack frame (subtract INT_FRAME_SIZE) before we check to see if the stack pointer is negative. Unfortunately, this won't detect a bad stack where r1 is less than INT_FRAME_SIZE. This patch fixes the check to compare the modified r1 with -INT_FRAME_SIZE. With this, bad kernel stack pointers (including NULL pointers) are correctly detected again. Kudos to Paulus for finding this. Signed-off-by: Michael Neuling <mikey@neuling.org> cc: stable@vger.kernel.org Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/include/asm/exception-64s.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 894662a5d4d5..243ce69ad685 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -284,7 +284,7 @@ do_kvm_##n: \
284 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ 284 subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \
285 beq- 1f; \ 285 beq- 1f; \
286 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 286 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \
2871: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \ 2871: cmpdi cr1,r1,-INT_FRAME_SIZE; /* check if r1 is in userspace */ \
288 blt+ cr1,3f; /* abort if it is */ \ 288 blt+ cr1,3f; /* abort if it is */ \
289 li r1,(n); /* will be reloaded later */ \ 289 li r1,(n); /* will be reloaded later */ \
290 sth r1,PACA_TRAP_SAVE(r13); \ 290 sth r1,PACA_TRAP_SAVE(r13); \