Skip to content

Commit d79d0d8

Browse files
dvyukovIngo Molnar
authored andcommitted
x86/mm: Clean up the printk()s in show_fault_oops()
- Remove 'nx_warning' and 'smep_warning', which are just pointless obfuscation. - Also convert to pr_crit(). Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Dmitry Vyukov <dvyukov@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20180627090715.28076-1-dvyukov@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent b8c1e42 commit d79d0d8

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

arch/x86/mm/fault.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -641,11 +641,6 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
641641
return 0;
642642
}
643643

644-
static const char nx_warning[] = KERN_CRIT
645-
"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
646-
static const char smep_warning[] = KERN_CRIT
647-
"unable to execute userspace code (SMEP?) (uid: %d)\n";
648-
649644
static void
650645
show_fault_oops(struct pt_regs *regs, unsigned long error_code,
651646
unsigned long address)
@@ -664,11 +659,13 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
664659
pte = lookup_address_in_pgd(pgd, address, &level);
665660

666661
if (pte && pte_present(*pte) && !pte_exec(*pte))
667-
printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
662+
pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
663+
from_kuid(&init_user_ns, current_uid()));
668664
if (pte && pte_present(*pte) && pte_exec(*pte) &&
669665
(pgd_flags(*pgd) & _PAGE_USER) &&
670666
(__read_cr4() & X86_CR4_SMEP))
671-
printk(smep_warning, from_kuid(&init_user_ns, current_uid()));
667+
pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",
668+
from_kuid(&init_user_ns, current_uid()));
672669
}
673670

674671
pr_alert("BUG: unable to handle kernel %s at %px\n",

0 commit comments

Comments
 (0)