Author: nwhitehorn
Date: Sun Dec  1 17:28:28 2013
New Revision: 258800
URL: http://svnweb.freebsd.org/changeset/base/258800

Log:
  The kernel stack guard pages are only below the stack pointer, not above.
  Prevent erroneous detection of stack overflows on legitimate faults on the
  page after this thread's stack.
  
  MFC after:    3 days

Modified:
  head/sys/powerpc/aim/trap_subr32.S
  head/sys/powerpc/aim/trap_subr64.S

Modified: head/sys/powerpc/aim/trap_subr32.S
==============================================================================
--- head/sys/powerpc/aim/trap_subr32.S  Sun Dec  1 17:00:57 2013        
(r258799)
+++ head/sys/powerpc/aim/trap_subr32.S  Sun Dec  1 17:28:28 2013        
(r258800)
@@ -664,11 +664,12 @@ disitrap:
        stw     %r31,(PC_TEMPSAVE+CPUSAVE_AIM_DSISR)(%r1)
 
 #ifdef KDB
-       /* Try and detect a kernel stack overflow */
+       /* Try to detect a kernel stack overflow */
        mfsrr1  %r31
        mtcr    %r31
        bt      17,realtrap             /* branch is user mode */
        mfsprg1 %r31                    /* get old SP */
+       clrrwi  %r31,%r31,11            /* Round SP down to nearest page */
        sub.    %r30,%r31,%r30          /* SP - DAR */
        bge     1f
        neg     %r30,%r30               /* modulo value */

Modified: head/sys/powerpc/aim/trap_subr64.S
==============================================================================
--- head/sys/powerpc/aim/trap_subr64.S  Sun Dec  1 17:00:57 2013        
(r258799)
+++ head/sys/powerpc/aim/trap_subr64.S  Sun Dec  1 17:28:28 2013        
(r258800)
@@ -569,11 +569,12 @@ disitrap:
        std     %r31,(PC_TEMPSAVE+CPUSAVE_AIM_DSISR)(%r1)
 
 #ifdef KDB
-       /* Try and detect a kernel stack overflow */
+       /* Try to detect a kernel stack overflow */
        mfsrr1  %r31
        mtcr    %r31
        bt      17,realtrap             /* branch is user mode */
        mfsprg1 %r31                    /* get old SP */
+       clrrdi  %r31,%r31,11            /* Round SP down to nearest page */
        sub.    %r30,%r31,%r30          /* SP - DAR */
        bge     1f
        neg     %r30,%r30               /* modulo value */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to