lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210128140208.30264-1-mikael.beckius@windriver.com>
Date:   Thu, 28 Jan 2021 15:02:08 +0100
From:   Mikael Beckius <mikael.beckius@...driver.com>
To:     <linux-kernel@...r.kernel.org>, <tglx@...utronix.de>
Subject: [PATCH] hrtimer: Interrupt storm on clock_settime

During clock_settime absolute realtime timers may get updated to expire
sooner in absolute monotonic time but if hrtimer_force_reprogram is
called as part of a clock_settime and the next hard hrtimer expires
before the next soft hrtimer softirq_expires_next will not be updated
to reflect this change (assuming the realtime timer is a soft timer).

This means that if the next soft hrtimer expires before
softirq_expires_next but after now no soft hrtimer interrupt will be
raised in hrtimer_interrupt which will instead retry tick_program_event
three times before forcing a tick_program_event using a very short delay
entering hrtimer_interrupt again almost immediately repeating the
process over and over again until now exceeds softirq_expires_next and a
soft hrtimer interrupt is finally raised.

This patch aims to solve this by always updating softirq_expires_next if
a soft hrtimer exists.

Signed-off-by: Mikael Beckius <mikael.beckius@...driver.com>
---
 kernel/time/hrtimer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 743c852e10f2..e4c233f404b1 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -633,7 +633,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
 	 */
 	expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL);
 
-	if (cpu_base->next_timer && cpu_base->next_timer->is_soft) {
+	if (cpu_base->softirq_next_timer) {
 		/*
 		 * When the softirq is activated, hrtimer has to be
 		 * programmed with the first hard hrtimer because soft
@@ -643,7 +643,8 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
 			expires_next = __hrtimer_get_next_event(cpu_base,
 								HRTIMER_ACTIVE_HARD);
 		else
-			cpu_base->softirq_expires_next = expires_next;
+			cpu_base->softirq_expires_next = __hrtimer_get_next_event(cpu_base,
+								HRTIMER_ACTIVE_SOFT);
 	}
 
 	if (skip_equal && expires_next == cpu_base->expires_next)
-- 
2.28.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ