From 99888f6b696f3bf5e10adc3822e146ffe7098bf0 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Thu, 13 Sep 2018 22:55:05 +0200 Subject: [PATCH] kernel: Apply user iframe determination logic to SMAP/SMEP. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I394492a289f01303ac28e6d6670fbfdb326fa4db Reviewed-on: https://review.haiku-os.org/561 Reviewed-by: Axel Dörfler --- src/system/kernel/arch/x86/arch_int.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_int.cpp b/src/system/kernel/arch/x86/arch_int.cpp index 1771dcc4ce..5588d5d181 100644 --- a/src/system/kernel/arch/x86/arch_int.cpp +++ b/src/system/kernel/arch/x86/arch_int.cpp @@ -327,7 +327,7 @@ x86_page_fault_exception(struct iframe* frame) panic("page fault not allowed at this place. Touching address " "%p from ip %p\n", (void*)cr2, (void*)frame->ip); return; - } else if ((frame->error_code & PGFAULT_U) == 0 + } else if (!IFRAME_IS_USER(frame) && (frame->error_code & PGFAULT_I) != 0 && (x86_read_cr4() & IA32_CR4_SMEP) != 0) { // check that: 1. come not from userland, @@ -335,7 +335,7 @@ x86_page_fault_exception(struct iframe* frame) panic("SMEP violation user-mapped address %p touched from kernel %p\n", (void*)cr2, (void*)frame->ip); } else if ((frame->flags & X86_EFLAGS_ALIGNMENT_CHECK) == 0 - && (frame->error_code & PGFAULT_U) == 0 + && !IFRAME_IS_USER(frame) && (frame->error_code & PGFAULT_P) != 0 && (x86_read_cr4() & IA32_CR4_SMAP) != 0) { // check that: 1. AC flag is not set, 2. come not from userland,