rtc: limit frequency
authorThomas Gleixner <tglx@linutronix.de>
Tue, 26 Jul 2011 23:08:19 +0000 (16:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Jul 2011 23:49:42 +0000 (16:49 -0700)
Due to the hrtimer self rearming mode a user can DoS the machine simply
because it's starved by hrtimer events.

The RTC hrtimer is self rearming.  We really need to limit the frequency
to something sensible.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Ben Greear <greearb@candelatech.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/interface.c

index b6bf57f25cc9e520ca31d642eea1616b9132f82b..601b053bc0e5782924ff2d3a3c97d332d26c2ac3 100644 (file)
@@ -688,7 +688,7 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
        int err = 0;
        unsigned long flags;
 
-       if (freq <= 0)
+       if (freq <= 0 || freq > 5000)
                return -EINVAL;
 
        spin_lock_irqsave(&rtc->irq_task_lock, flags);