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 <m...@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
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to