Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Aug 2018 02:51:37 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r337230 - head/sys/x86/x86
Message-ID:  <201808030251.w732pbxx017911@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Fri Aug  3 02:51:37 2018
New Revision: 337230
URL: https://svnweb.freebsd.org/changeset/base/337230

Log:
  Verify that each frame pointer lies within the thread's kstack.
  
  Previously, this check was omitted for the first frame pointer.
  
  Reported by:	pho
  Reviewed by:	kib
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D16572

Modified:
  head/sys/x86/x86/stack_machdep.c

Modified: head/sys/x86/x86/stack_machdep.c
==============================================================================
--- head/sys/x86/x86/stack_machdep.c	Fri Aug  3 02:16:45 2018	(r337229)
+++ head/sys/x86/x86/stack_machdep.c	Fri Aug  3 02:51:37 2018	(r337230)
@@ -82,16 +82,16 @@ stack_capture(struct thread *td, struct stack *st, reg
 	stack_zero(st);
 	frame = (x86_frame_t)fp;
 	while (1) {
-		if (!INKERNEL((long)frame))
+		if ((vm_offset_t)frame < td->td_kstack ||
+		    (vm_offset_t)frame >= td->td_kstack +
+		    td->td_kstack_pages * PAGE_SIZE)
 			break;
 		callpc = frame->f_retaddr;
 		if (!INKERNEL(callpc))
 			break;
 		if (stack_put(st, callpc) == -1)
 			break;
-		if (frame->f_frame <= frame ||
-		    (vm_offset_t)frame->f_frame >= td->td_kstack +
-		    td->td_kstack_pages * PAGE_SIZE)
+		if (frame->f_frame <= frame)
 			break;
 		frame = frame->f_frame;
 	}
@@ -106,7 +106,7 @@ stack_nmi_handler(struct trapframe *tf)
 	if (nmi_stack == NULL || curthread != nmi_pending)
 		return (0);
 
-	if (INKERNEL(TF_PC(tf)) && (TF_FLAGS(tf) & PSL_I) != 0)
+	if (!TRAPF_USERMODE(tf) && (TF_FLAGS(tf) & PSL_I) != 0)
 		stack_capture(curthread, nmi_stack, TF_FP(tf));
 	else
 		/* We were running in usermode or had interrupts disabled. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808030251.w732pbxx017911>