Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Aug 2017 17:11:15 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r322667 - head/sys/i386/i386
Message-ID:  <201708181711.v7IHBFtO036108@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Aug 18 17:11:15 2017
New Revision: 322667
URL: https://svnweb.freebsd.org/changeset/base/322667

Log:
  When checking that #UD comes from kernel mode, check that the
  exception did not happen in vm86 mode.  A vm86 userland process could
  have a %cs that matches GSEL_KPL, while dtrace cannot hook it.
  
  Submitted by:	Maxime Villard <max@m00nbsd.net>
  MFC after:	3 days

Modified:
  head/sys/i386/i386/exception.s

Modified: head/sys/i386/i386/exception.s
==============================================================================
--- head/sys/i386/i386/exception.s	Fri Aug 18 16:43:59 2017	(r322666)
+++ head/sys/i386/i386/exception.s	Fri Aug 18 17:11:15 2017	(r322667)
@@ -187,11 +187,14 @@ IDTVEC(ill)
 	cmpl	$0,dtrace_invop_jump_addr
 	je	norm_ill
 
-	/* Check if this is a user fault. */
-	cmpl	$GSEL_KPL, 4(%esp)	/* Check the code segment. */
-
-	/* If so, just handle it as a normal trap. */
+	/*
+	 * Check if this is a user fault. If so, just handle it as a normal
+	 * trap.
+	 */
+	cmpl	$GSEL_KPL, 4(%esp)	/* Check the code segment */
 	jne	norm_ill
+	testl	$PSL_VM, 8(%esp)	/* and vm86 mode. */
+	jnz	norm_ill
 
 	/*
 	 * This is a kernel instruction fault that might have been caused



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