aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2014-06-10 16:49:31 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-06-11 20:55:30 -0400
commiteff50c347fcc8feeb8c1723c23c89aba67c60263 (patch)
treeb6c7182ebd6f8b4c6eb8301cb9cd485f3f6f0cfc
parented81e780a7dd5698a986f246fad6a1d8d0b6f9ce (diff)
x86/smep: Be more informative when signalling an SMEP fault
If pagefault triggers due to SMEP triggering, it can't be really easily distinguished from any other oops-causing pagefault, which might lead to quite some confusion when trying to understand the reason for the oops. Print an explanatory message in case the fault happened during instruction fetch for _PAGE_USER page which is present and executable on SMEP-enabled CPUs. This is consistent with what we are doing for NX already; in addition to immediately seeing from the oops what might be happening, it can even easily give a good indication to sysadmins who are carefully monitoring their kernel logs that someone might be trying to pwn them. Signed-off-by: Jiri Kosina <jkosina@suse.cz> Link: http://lkml.kernel.org/r/alpine.LNX.2.00.1406102248490.1321@pobox.suse.cz Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--arch/x86/mm/fault.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 858b47b5221b..9de4cdbf1245 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -575,6 +575,8 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
575 575
576static const char nx_warning[] = KERN_CRIT 576static const char nx_warning[] = KERN_CRIT
577"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n"; 577"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
578static const char smep_warning[] = KERN_CRIT
579"unable to execute userspace code (SMEP?) (uid: %d)\n";
578 580
579static void 581static void
580show_fault_oops(struct pt_regs *regs, unsigned long error_code, 582show_fault_oops(struct pt_regs *regs, unsigned long error_code,
@@ -595,6 +597,10 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
595 597
596 if (pte && pte_present(*pte) && !pte_exec(*pte)) 598 if (pte && pte_present(*pte) && !pte_exec(*pte))
597 printk(nx_warning, from_kuid(&init_user_ns, current_uid())); 599 printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
600 if (pte && pte_present(*pte) && pte_exec(*pte) &&
601 (pgd_flags(*pgd) & _PAGE_USER) &&
602 (read_cr4() & X86_CR4_SMEP))
603 printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
598 } 604 }
599 605
600 printk(KERN_ALERT "BUG: unable to handle kernel "); 606 printk(KERN_ALERT "BUG: unable to handle kernel ");