fastcall void _kprobes do_page_fault(struct pt_regs *regs, unsigned long error_code)
/* Are we prepared to handle this kernel fault? */ if (fixup_exception(regs)) return;
* Oops. The kernel tried to access some bad page. We'll have to
* terminate things with extreme prejudice.
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 eip: %08lx ", regs->eip);
page = ((_typeof_(page) *) _va(page))[address >> PGDIR_SHIFT];
tsk->thread.cr2 = address; tsk->thread.trap_no = 14; tsk->thread.error_code = error_code; die("Oops", regs, error_code); do_exit(SIGKILL);
If a virtual address between 0 and page_size - 1 is accessed, the kernel reports an invalid null pointer de-reference. Otherwise, the user is informed that a paging request could not be satisfied in kernel memory — this is a kernel bug in both cases. Additional information is also output to help debug the fault and to supply hardware-specific data; die prints the contents of the current registers (among other things).
Thereafter, the current process is forced to terminate with sigkill to save whatever can be saved (in many cases, the system is rendered unusable by a fault of this kind).
Continue reading here: Copying Data between Kernel and Userspace
Was this article helpful?