alarmtimer: don't rate limit one-shot timers
authorGreg Hackmann <ghackmann@google.com>
Mon, 24 Jul 2017 17:19:24 +0000 (10:19 -0700)
committerDanny Wood <danwood76@gmail.com>
Tue, 28 Sep 2021 12:06:42 +0000 (13:06 +0100)
Commit ff86bf0c65f1 ("alarmtimer: Rate limit periodic intervals") sets a
minimum bound on the alarm timer interval.  This minimum bound shouldn't
be applied if the interval is 0.  Otherwise, one-shot timers will be
converted into periodic ones.

Fixes: ff86bf0c65f1 ("alarmtimer: Rate limit periodic intervals")
Change-Id: I3dd6cb7b5caec3d39b956489448c19d3cda41e5c
Reported-by: Ben Fennema <fennema@google.com>
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Cc: stable@vger.kernel.org
Cc: John Stultz <john.stultz@linaro.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
kernel/time/alarmtimer.c

index d19d10792b864ee03bc1418fe93b7c2bbcb8ff77..765eec6f49cf973f5bb4cd9fb23ed49855e8aa24 100644 (file)
@@ -607,7 +607,8 @@ static int alarm_timer_set(struct k_itimer *timr, int flags,
         * Rate limit to the tick as a hot fix to prevent DOS. Will be
         * mopped up later.
         */
-       if (ktime_to_ns(timr->it.alarm.interval) < TICK_NSEC)
+       if (timr->it.alarm.interval.tv64 &&
+                       ktime_to_ns(timr->it.alarm.interval) < TICK_NSEC)
                timr->it.alarm.interval = ktime_set(0, TICK_NSEC);
 
        exp = timespec_to_ktime(new_setting->it_value);