Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 80554
b: refs/heads/master
c: b3279c7
h: refs/heads/master
v: v3
  • Loading branch information
Harvey Harrison authored and Ingo Molnar committed Jan 30, 2008
1 parent 1cc3b69 commit 38db567
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 35f3266ffbee7ff8ca0474dc8dfa3b73d5a1d1ef
refs/heads/master: b3279c7fd7acf807ab8395d16658514e8c222a37
54 changes: 30 additions & 24 deletions trunk/arch/x86/mm/fault_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,35 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
return 0;
}

static void show_fault_oops(struct pt_regs *regs, unsigned long error_code,
unsigned long address)
{
if (!oops_may_print())
return;

#ifdef CONFIG_X86_PAE
if (error_code & PF_INSTR) {
int level;
pte_t *pte = lookup_address(address, &level);

if (pte && pte_present(*pte) && !pte_exec(*pte))
printk(KERN_CRIT "kernel tried to execute "
"NX-protected page - exploit attempt? "
"(uid: %d)\n", current->uid);
}
#endif
if (address < PAGE_SIZE)
printk(KERN_ALERT "BUG: unable to handle kernel NULL "
"pointer dereference");
else
printk(KERN_ALERT "BUG: unable to handle kernel paging"
" request");
printk(" at virtual address %08lx\n", address);
printk(KERN_ALERT "printing ip: %08lx ", regs->ip);

dump_pagetable(address);
}

/*
* Handle a fault on the vmalloc or module mapping area
*
Expand Down Expand Up @@ -633,30 +662,7 @@ void __kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)

bust_spinlocks(1);

if (oops_may_print()) {

#ifdef CONFIG_X86_PAE
if (error_code & PF_INSTR) {
int level;
pte_t *pte = lookup_address(address, &level);

if (pte && pte_present(*pte) && !pte_exec(*pte))
printk(KERN_CRIT "kernel tried to execute "
"NX-protected page - exploit attempt? "
"(uid: %d)\n", current->uid);
}
#endif
if (address < PAGE_SIZE)
printk(KERN_ALERT "BUG: unable to handle kernel NULL "
"pointer dereference");
else
printk(KERN_ALERT "BUG: unable to handle kernel paging"
" request");
printk(" at virtual address %08lx\n", address);
printk(KERN_ALERT "printing ip: %08lx ", regs->ip);

dump_pagetable(address);
}
show_fault_oops(regs, error_code, address);

tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
Expand Down
21 changes: 14 additions & 7 deletions trunk/arch/x86/mm/fault_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
return 0;
}

static void show_fault_oops(struct pt_regs *regs, unsigned long error_code,
unsigned long address)
{
if (address < PAGE_SIZE)
printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
else
printk(KERN_ALERT "Unable to handle kernel paging request");
printk(" at %016lx RIP: \n" KERN_ALERT, address);
printk_address(regs->ip, 1);
dump_pagetable(address);
}

static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
unsigned long error_code)
{
Expand Down Expand Up @@ -636,13 +648,8 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,

flags = oops_begin();

if (address < PAGE_SIZE)
printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
else
printk(KERN_ALERT "Unable to handle kernel paging request");
printk(" at %016lx RIP: \n" KERN_ALERT, address);
printk_address(regs->ip, 1);
dump_pagetable(address);
show_fault_oops(regs, error_code, address);

tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
tsk->thread.error_code = error_code;
Expand Down

0 comments on commit 38db567

Please sign in to comment.