Skip to content

Commit d29dc51

Browse files
jgross1Ingo Molnar
authored andcommitted
x86/mm: Use lookup_address_in_pgd_attr() in show_fault_oops()
Fix show_fault_oops() to not only look at the leaf PTE for detecting NX violations, but to use the effective NX value returned by lookup_address_in_pgd_attr() instead. Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ceb647b commit d29dc51

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/x86/mm/fault.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,18 +514,19 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad
514514

515515
if (error_code & X86_PF_INSTR) {
516516
unsigned int level;
517+
bool nx, rw;
517518
pgd_t *pgd;
518519
pte_t *pte;
519520

520521
pgd = __va(read_cr3_pa());
521522
pgd += pgd_index(address);
522523

523-
pte = lookup_address_in_pgd(pgd, address, &level);
524+
pte = lookup_address_in_pgd_attr(pgd, address, &level, &nx, &rw);
524525

525-
if (pte && pte_present(*pte) && !pte_exec(*pte))
526+
if (pte && pte_present(*pte) && (!pte_exec(*pte) || nx))
526527
pr_crit("kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n",
527528
from_kuid(&init_user_ns, current_uid()));
528-
if (pte && pte_present(*pte) && pte_exec(*pte) &&
529+
if (pte && pte_present(*pte) && pte_exec(*pte) && !nx &&
529530
(pgd_flags(*pgd) & _PAGE_USER) &&
530531
(__read_cr4() & X86_CR4_SMEP))
531532
pr_crit("unable to execute userspace code (SMEP?) (uid: %d)\n",

0 commit comments

Comments
 (0)