From c2ac4cd321c7cb34f39d69c79903783478a61b00 Mon Sep 17 00:00:00 2001 From: Salvatore Bonaccorso Date: Sat, 12 Jan 2019 11:23:21 +0100 Subject: [PATCH] posix-cpu-timers: Unbreak timer rearming Closes: #919019 Closes: #919049 --- debian/changelog | 1 + ...ix-cpu-timers-Unbreak-timer-rearming.patch | 52 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 54 insertions(+) create mode 100644 debian/patches/bugfix/all/posix-cpu-timers-Unbreak-timer-rearming.patch diff --git a/debian/changelog b/debian/changelog index f7cade43d..d8862b908 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ linux (4.19.13-2) UNRELEASED; urgency=medium [ Salvatore Bonaccorso ] * ipv6: Consider sk_bound_dev_if when binding a socket to an address (Closes: #918103) + * posix-cpu-timers: Unbreak timer rearming (Closes: #919019, #919049) [ Michal Simek ] * [arm64] Enable Xilinx ZynqMP SoC and drivers diff --git a/debian/patches/bugfix/all/posix-cpu-timers-Unbreak-timer-rearming.patch b/debian/patches/bugfix/all/posix-cpu-timers-Unbreak-timer-rearming.patch new file mode 100644 index 000000000..dec4c64f9 --- /dev/null +++ b/debian/patches/bugfix/all/posix-cpu-timers-Unbreak-timer-rearming.patch @@ -0,0 +1,52 @@ +From: Thomas Gleixner +Date: Fri, 11 Jan 2019 14:33:16 +0100 +Subject: posix-cpu-timers: Unbreak timer rearming +Origin: https://lore.kernel.org/lkml/20190111133500.840117406@linutronix.de/ +Bug-Debian: https://bugs.debian.org/919019 +Bug-Debian: https://bugs.debian.org/919049 + +The recent commit which prevented a division by 0 issue in the alarm timer +code broke posix CPU timers as an unwanted side effect. + +The reason is that the common rearm code checks for timer->it_interval +being 0 now. What went unnoticed is that the posix cpu timer setup does not +initialize timer->it_interval as it stores the interval in CPU timer +specific storage. The reason for the separate storage is historical as the +posix CPU timers always had a 64bit nanoseconds representation internally +while timer->it_interval is type ktime_t which used to be a modified +timespec representation on 32bit machines. + +Instead of reverting the offending commit and fixing the alarmtimer issue +in the alarmtimer code, store the interval in timer->it_interval at CPU +timer setup time so the common code check works. This also repairs the +existing inconistency of the posix CPU timer code which kept a single shot +timer armed despite of the interval being 0. + +The separate storage can be removed in mainline, but that needs to be a +separate commit as the current one has to be backported to stable kernels. + +Fixes: 0e334db6bb4b ("posix-timers: Fix division by zero bug") +Reported-by: H.J. Lu +Signed-off-by: Thomas Gleixner +Cc: stable@vger.kernel.org +Cc: Peter Zijlstra +Cc: John Stultz +--- + kernel/time/posix-cpu-timers.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c +index 8f0644af40be..80f955210861 100644 +--- a/kernel/time/posix-cpu-timers.c ++++ b/kernel/time/posix-cpu-timers.c +@@ -685,6 +685,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags, + * set up the signal and overrun bookkeeping. + */ + timer->it.cpu.incr = timespec64_to_ns(&new->it_interval); ++ timer->it_interval = ns_to_ktime(timer->it.cpu.incr); + + /* + * This acts as a modification timestamp for the timer, +-- +2.20.1 + diff --git a/debian/patches/series b/debian/patches/series index b85775927..56da1c4e6 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -102,6 +102,7 @@ bugfix/all/kbuild-include-addtree-remove-quotes-before-matching-path.patch debian/revert-objtool-fix-config_stack_validation-y-warning.patch bugfix/all/smb3-fix-large-reads-on-encrypted-connections.patch bugfix/all/ipv6-Consider-sk_bound_dev_if-when-binding-a-socket-.patch +bugfix/all/posix-cpu-timers-Unbreak-timer-rearming.patch # Miscellaneous features