All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Ratelimit printks due to unhandled signals in x86_64
@ 2007-06-09 18:38 Masoud Asgharifard Sharbiani
  0 siblings, 0 replies; only message in thread
From: Masoud Asgharifard Sharbiani @ 2007-06-09 18:38 UTC (permalink / raw)
  To: bunk; +Cc: linux-kernel

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 <masouds@google.com>

diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 5876df1..4b3cd29 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -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); 
 
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index a5209fd..4f22aaa 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -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,
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 2e7c3c8..92f6448 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -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,

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-06-09 18:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-09 18:38 [PATCH] Ratelimit printks due to unhandled signals in x86_64 Masoud Asgharifard Sharbiani

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.