Created
April 8, 2011 15:47
-
-
Save baulig/910150 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void | |
__do_user_fault(struct task_struct *tsk, unsigned long addr, | |
unsigned int fsr, unsigned int sig, int code, | |
struct pt_regs *regs) | |
{ | |
struct siginfo si; | |
struct task_struct *g, *p, *selected = NULL; | |
#ifdef CONFIG_DEBUG_USER | |
if (user_debug & UDBG_SEGV) { | |
printk(KERN_DEBUG "%s: unhandled page fault (%d) at 0x%08lx, code 0x%03x\n", | |
tsk->comm, sig, addr, fsr); | |
show_pte(tsk->mm, addr); | |
show_regs(regs); | |
} | |
#endif | |
if (sig == SIGSEGV) | |
tsk->segfault_count++; | |
if (tsk->segfault_count > 10) { | |
tsk->segfault_count = 0; | |
printk(KERN_ERR "unhandled page fault at 0x%08lx, code 0x%03x\n", | |
addr, fsr); | |
show_pte(tsk->mm, addr); | |
show_regs(regs); | |
do_each_thread(g, p) { | |
task_lock(p); | |
if (p == tsk) | |
selected = g; | |
task_unlock(p); | |
} while_each_thread(g, p); | |
if (selected) { | |
printk(KERN_ERR "%s: triggered too many segfaults, force killing parent: %s\n", | |
tsk->comm, selected->comm); | |
force_sig(SIGKILL, selected); | |
return; | |
} | |
} | |
tsk->thread.address = addr; | |
tsk->thread.error_code = fsr; | |
tsk->thread.trap_no = 14; | |
si.si_signo = sig; | |
si.si_errno = 0; | |
si.si_code = code; | |
si.si_addr = (void __user *)addr; | |
force_sig_info(sig, &si, tsk); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment