]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.18-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Nov 2017 16:51:45 +0000 (17:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Nov 2017 16:51:45 +0000 (17:51 +0100)
added patches:
time-always-make-sure-wall_to_monotonic-isn-t-positive.patch

queue-3.18/series
queue-3.18/time-always-make-sure-wall_to_monotonic-isn-t-positive.patch [new file with mode: 0644]

index 0d50069d81e0580de5364ef1c39927c7b8a064c2..c1ce3f68c5eb6beb2903173f53cd9ea7c7dbb948 100644 (file)
@@ -31,3 +31,4 @@ clk-ti-dra7-atl-clock-fix-of_node-reference-counting.patch
 clk-ti-dra7-atl-clock-fix-child-node-lookups.patch
 ib-srpt-do-not-accept-invalid-initiator-port-names.patch
 nfc-fix-device-allocation-error-return.patch
+time-always-make-sure-wall_to_monotonic-isn-t-positive.patch
diff --git a/queue-3.18/time-always-make-sure-wall_to_monotonic-isn-t-positive.patch b/queue-3.18/time-always-make-sure-wall_to_monotonic-isn-t-positive.patch
new file mode 100644 (file)
index 0000000..97e3528
--- /dev/null
@@ -0,0 +1,111 @@
+From e1d7ba8735551ed79c7a0463a042353574b96da3 Mon Sep 17 00:00:00 2001
+From: Wang YanQing <udknight@gmail.com>
+Date: Tue, 23 Jun 2015 18:38:54 +0800
+Subject: time: Always make sure wall_to_monotonic isn't positive
+
+From: Wang YanQing <udknight@gmail.com>
+
+commit e1d7ba8735551ed79c7a0463a042353574b96da3 upstream.
+
+Two issues were found on an IMX6 development board without an
+enabled RTC device(resulting in the boot time and monotonic
+time being initialized to 0).
+
+Issue 1:exportfs -a generate:
+       "exportfs: /opt/nfs/arm does not support NFS export"
+Issue 2:cat /proc/stat:
+       "btime 4294967236"
+
+The same issues can be reproduced on x86 after running the
+following code:
+       int main(void)
+       {
+           struct timeval val;
+           int ret;
+
+           val.tv_sec = 0;
+           val.tv_usec = 0;
+           ret = settimeofday(&val, NULL);
+           return 0;
+       }
+
+Two issues are different symptoms of same problem:
+The reason is a positive wall_to_monotonic pushes boot time back
+to the time before Epoch, and getboottime will return negative
+value.
+
+In symptom 1:
+          negative boot time cause get_expiry() to overflow time_t
+          when input expire time is 2147483647, then cache_flush()
+          always clears entries just added in ip_map_parse.
+In symptom 2:
+          show_stat() uses "unsigned long" to print negative btime
+          value returned by getboottime.
+
+This patch fix the problem by prohibiting time from being set to a value which
+would cause a negative boot time. As a result one can't set the CLOCK_REALTIME
+time prior to (1970 + system uptime).
+
+Cc: Prarit Bhargava <prarit@redhat.com>
+Cc: Richard Cochran <richardcochran@gmail.com>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Signed-off-by: Wang YanQing <udknight@gmail.com>
+[jstultz: reworded commit message]
+[msfjarvis: Backport to 3.18 as we are missing the do_settimeofday64
+function the upstream commit patches, so we apply the changes to
+do_settimeofday]
+Signed-off-by: John Stultz <john.stultz@linaro.org>
+Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/time/timekeeping.c |   13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
+--- a/kernel/time/timekeeping.c
++++ b/kernel/time/timekeeping.c
+@@ -712,6 +712,7 @@ int do_settimeofday(const struct timespe
+       struct timekeeper *tk = &tk_core.timekeeper;
+       struct timespec64 ts_delta, xt, tmp;
+       unsigned long flags;
++      int ret = 0;
+       if (!timespec_valid_strict(tv))
+               return -EINVAL;
+@@ -725,11 +726,16 @@ int do_settimeofday(const struct timespe
+       ts_delta.tv_sec = tv->tv_sec - xt.tv_sec;
+       ts_delta.tv_nsec = tv->tv_nsec - xt.tv_nsec;
++      if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) {
++              ret = -EINVAL;
++              goto out;
++      }
++
+       tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta));
+       tmp = timespec_to_timespec64(*tv);
+       tk_set_xtime(tk, &tmp);
+-
++out:
+       timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET);
+       write_seqcount_end(&tk_core.seq);
+@@ -738,7 +744,7 @@ int do_settimeofday(const struct timespe
+       /* signal hrtimers about time change */
+       clock_was_set();
+-      return 0;
++      return ret;
+ }
+ EXPORT_SYMBOL(do_settimeofday);
+@@ -767,7 +773,8 @@ int timekeeping_inject_offset(struct tim
+       /* Make sure the proposed value is valid */
+       tmp = timespec64_add(tk_xtime(tk),  ts64);
+-      if (!timespec64_valid_strict(&tmp)) {
++      if (timespec64_compare(&tk->wall_to_monotonic, &ts64) > 0 ||
++              !timespec64_valid_strict(&tmp)) {
+               ret = -EINVAL;
+               goto error;
+       }