Ratelimit printks due to unhandled signals in x86_64
PATCH 1/1 Ratelimit printks due to unhandled signals in x86_64
Hello,
The following patch enables ratelimiting of unhandled signals in x86_64. Without this, a malicious user could inflict local DoS and fill up the logs with a code like this:
main()
{
while(1)
if (!fork())
*(int *)0 = 0;
}The patch is against 2.6.16.y tree. I've sent a similar one to Andrew for inclusion in the -mm tree.
cheers,
Masoud
Signed-off-by Masoud Sharbiani <[email protected]>
arch/x86_64/kernel/signal.c +1 -1
@@ -505,7 +505,7 @@ void do_notify_resume(struct pt_regs *regs, sigset_t *oldset, __u32 thread_info_void signal_fault (struct pt_regs *regs,void __user *frame,char *where) {struct task_struct *me = current; -if (exception_trace) +if (exception_trace &&printk_ratelimit ())printk ("%s[%d] bad frame in %s frame:%p rip:%lx rsp:%lx orax:%lx\n" , me->comm,me->pid,where,frame,regs->rip,regs->rsp,regs->orig_rax);
arch/x86_64/kernel/traps.c +2 -1
@@ -480,7 +480,8 @@ static void __kprobes do_trap(int trapnr, int signr, char *str, tsk->thread.trap_no = trapnr;if (user_mode (regs)) { -if (exception_trace &&unhandled_signal (tsk, signr)) +if (exception_trace &&unhandled_signal (tsk, signr) && +printk_ratelimit ()) printk(KERN_INFO "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n", tsk->comm, tsk->pid, str,
arch/x86_64/mm/fault.c +2 -1
@@ -475,7 +475,8 @@ bad_area_nosemaphore: (address >> 32))return ; -if (exception_trace &&unhandled_signal (tsk,SIGSEGV )) { +if (exception_trace &&unhandled_signal (tsk,SIGSEGV ) && +printk_ratelimit ()) { printk( "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n", tsk->pid > 1 ? KERN_INFO : KERN_EMERG,