Author: kib
Date: Sun Sep  2 20:07:36 2018
New Revision: 338434
URL: https://svnweb.freebsd.org/changeset/base/338434

Log:
  Swap order of dererencing PCPU curpmap and checking for usermode in
  trap_pfault() KPTI violation check.
  
  EFI RT may set curpmap to NULL for the duration of the call for some
  machines (PCID but no INVPCID).  Since apparently EFI RT code must be
  ready for exceptions from the calls, avoid dereferencing curpmap until
  we know that this call does not come from usermode.
  
  Reviewed by:  kevans
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week
  Approved by:    re (rgrimes)
  Differential revision:        https://reviews.freebsd.org/D16972

Modified:
  head/sys/amd64/amd64/trap.c

Modified: head/sys/amd64/amd64/trap.c
==============================================================================
--- head/sys/amd64/amd64/trap.c Sun Sep  2 19:48:41 2018        (r338433)
+++ head/sys/amd64/amd64/trap.c Sun Sep  2 20:07:36 2018        (r338434)
@@ -806,7 +806,7 @@ trap_pfault(struct trapframe *frame, int usermode)
         * If nx protection of the usermode portion of kernel page
         * tables caused trap, panic.
         */
-       if (PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 && usermode &&
+       if (usermode && PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 &&
            pg_nx != 0 && (frame->tf_err & (PGEX_P | PGEX_W |
            PGEX_U | PGEX_I)) == (PGEX_P | PGEX_U | PGEX_I) &&
            (curpcb->pcb_saved_ucr3 & ~CR3_PCID_MASK)==
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to