path: root/sys
diff options
authorKonstantin Belousov <kib@FreeBSD.org>2018-09-02 20:07:36 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2018-09-02 20:07:36 +0000
commit9eb958988a31a375385b4ff1088ab9da6e55c2de (patch)
treee90edf997549503fd5f420401b0153d30ae7cefa /sys
parentd4be3789fe21e918ea3bdb498102ef12ffa21626 (diff)
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
Notes: svn path=/head/; revision=338434
Diffstat (limited to 'sys')
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 019decb837ac..4d03da234f19 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -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)==