From d85713a82eddda8e52a276767be747e905f99df0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 19 Jun 2017 22:17:00 +0800 Subject: [PATCH] 3.18-stable patches added patches: alarmtimer-rate-limit-periodic-intervals.patch --- ...mtimer-rate-limit-periodic-intervals.patch | 61 +++++++++++++++++++ queue-3.18/series | 1 + 2 files changed, 62 insertions(+) create mode 100644 queue-3.18/alarmtimer-rate-limit-periodic-intervals.patch diff --git a/queue-3.18/alarmtimer-rate-limit-periodic-intervals.patch b/queue-3.18/alarmtimer-rate-limit-periodic-intervals.patch new file mode 100644 index 00000000000..45f8d06a28a --- /dev/null +++ b/queue-3.18/alarmtimer-rate-limit-periodic-intervals.patch @@ -0,0 +1,61 @@ +From ff86bf0c65f14346bf2440534f9ba5ac232c39a0 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner +Date: Tue, 30 May 2017 23:15:35 +0200 +Subject: alarmtimer: Rate limit periodic intervals + +From: Thomas Gleixner + +commit ff86bf0c65f14346bf2440534f9ba5ac232c39a0 upstream. + +The alarmtimer code has another source of potentially rearming itself too +fast. Interval timers with a very samll interval have a similar CPU hog +effect as the previously fixed overflow issue. + +The reason is that alarmtimers do not implement the normal protection +against this kind of problem which the other posix timer use: + + timer expires -> queue signal -> deliver signal -> rearm timer + +This scheme brings the rearming under scheduler control and prevents +permanently firing timers which hog the CPU. + +Bringing this scheme to the alarm timer code is a major overhaul because it +lacks all the necessary mechanisms completely. + +So for a quick fix limit the interval to one jiffie. This is not +problematic in practice as alarmtimers are usually backed by an RTC for +suspend which have 1 second resolution. It could be therefor argued that +the resolution of this clock should be set to 1 second in general, but +that's outside the scope of this fix. + +Signed-off-by: Thomas Gleixner +Cc: Peter Zijlstra +Cc: Kostya Serebryany +Cc: syzkaller +Cc: John Stultz +Cc: Dmitry Vyukov +Link: http://lkml.kernel.org/r/20170530211655.896767100@linutronix.de +Signed-off-by: Greg Kroah-Hartman + + +--- + kernel/time/alarmtimer.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/kernel/time/alarmtimer.c ++++ b/kernel/time/alarmtimer.c +@@ -614,6 +614,14 @@ static int alarm_timer_set(struct k_itim + + /* start the timer */ + timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval); ++ ++ /* ++ * 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) ++ timr->it.alarm.interval = ktime_set(0, TICK_NSEC); ++ + exp = timespec_to_ktime(new_setting->it_value); + /* Convert (if necessary) to absolute time */ + if (flags != TIMER_ABSTIME) { diff --git a/queue-3.18/series b/queue-3.18/series index 366e8af442d..08b37b547c3 100644 --- a/queue-3.18/series +++ b/queue-3.18/series @@ -28,3 +28,4 @@ usb-xhci-asmedia-asm1042a-chipset-need-shorts-tx-quirk.patch mm-memory-failure.c-use-compound_head-flags-for-huge-pages.patch swap-cond_resched-in-swap_cgroup_prepare.patch genirq-release-resources-in-__setup_irq-error-path.patch +alarmtimer-rate-limit-periodic-intervals.patch -- 2.47.3