From 4d20e87b7e2b762efcf4880fb636dc9b066ad6b6 Mon Sep 17 00:00:00 2001 From: Tycho Nightingale Date: Fri, 8 Jun 2018 20:35:58 +0000 Subject: [PATCH] Don't bother looking for non-executable pages when a process is excluded from PTI. Reviewed by: kib Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D15708 --- sys/amd64/amd64/trap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 362f349a1d90..0049e82d190c 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -770,7 +770,8 @@ trap_pfault(struct trapframe *frame, int usermode) * If nx protection of the usermode portion of kernel page * tables caused trap, panic. */ - if (pti && usermode && pg_nx != 0 && (frame->tf_err & (PGEX_P | PGEX_W | + if (PCPU_GET(curpmap)->pm_ucr3 != PMAP_NO_CR3 && usermode && + 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)== (PCPU_GET(curpmap)->pm_cr3 & ~CR3_PCID_MASK))