]> git.proxmox.com Git - pve-kernel-jessie.git/commitdiff
Backport ntp clock_adjtime fix from 4.5
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 15 Apr 2016 07:05:03 +0000 (09:05 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 15 Apr 2016 07:29:13 +0000 (09:29 +0200)
this broke NTP synchronization with systemd-timesyncd for
all time deltas where a jump was necessary (>= 0.4s).

Makefile
ntp-Fix-ADJ_SETOFFSET-being-used-w-ADJ_NANO.patch [new file with mode: 0644]

index 46f8da34bd7a95dc2deb5b2081f254bd68e10368..e7c595bc3dd737506ed1e01e67af932cba8df034 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -237,6 +237,7 @@ ${KERNEL_SRC}/README ${KERNEL_CFG_ORG}: ${KERNELSRCTAR}
        cd ${KERNEL_SRC}; patch -p1 <../override_for_missing_acs_capabilities.patch
        #cd ${KERNEL_SRC}; patch -p1 <../vhost-net-extend-device-allocation-to-vmalloc.patch
        cd ${KERNEL_SRC}; patch -p1 <../apparmor-fix-bad--include-path.patch
+       cd ${KERNEL_SRC}; patch -p1 <../ntp-Fix-ADJ_SETOFFSET-being-used-w-ADJ_NANO.patch
        sed -i ${KERNEL_SRC}/Makefile -e 's/^EXTRAVERSION.*$$/EXTRAVERSION=${EXTRAVERSION}/'
        touch $@
 
diff --git a/ntp-Fix-ADJ_SETOFFSET-being-used-w-ADJ_NANO.patch b/ntp-Fix-ADJ_SETOFFSET-being-used-w-ADJ_NANO.patch
new file mode 100644 (file)
index 0000000..6ee4abe
--- /dev/null
@@ -0,0 +1,57 @@
+From: John Stultz <john.stultz@linaro.org>
+
+BugLink: http://bugs.launchpad.net/bugs/1566465
+
+Recently, in commit 37cf4dc3370f I forgot to check if the timeval being passed
+was actually a timespec (as is signaled with ADJ_NANO).
+
+This resulted in that patch breaking ADJ_SETOFFSET users who set
+ADJ_NANO, by rejecting valid timespecs that were compared with
+valid timeval ranges.
+
+This patch addresses this by checking for the ADJ_NANO flag and
+using the timepsec check instead in that case.
+
+Reported-by: Harald Hoyer <harald@redhat.com>
+Reported-by: Kay Sievers <kay@vrfy.org>
+Fixes: 37cf4dc3370f "time: Verify time values in adjtimex ADJ_SETOFFSET to avoid overflow"
+Signed-off-by: John Stultz <john.stultz@linaro.org>
+Cc: Sasha Levin <sasha.levin@oracle.com>
+Cc: Richard Cochran <richardcochran@gmail.com>
+Cc: Prarit Bhargava <prarit@redhat.com>
+Cc: David Herrmann <dh.herrmann@gmail.com>
+Link: http://lkml.kernel.org/r/1453417415-19110-2-git-send-email-john.stultz@linaro.org
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+(cherry picked from commit dd4e17ab704269bce71402285f5e8b9ac24b1eff)
+Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
+---
+ kernel/time/ntp.c | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
+index d7654e2..ab86177 100644
+--- a/kernel/time/ntp.c
++++ b/kernel/time/ntp.c
+@@ -679,8 +679,18 @@ int ntp_validate_timex(struct timex *txc)
+               if (!capable(CAP_SYS_TIME))
+                       return -EPERM;
+-              if (!timeval_inject_offset_valid(&txc->time))
+-                      return -EINVAL;
++              if (txc->modes & ADJ_NANO) {
++                      struct timespec ts;
++
++                      ts.tv_sec = txc->time.tv_sec;
++                      ts.tv_nsec = txc->time.tv_usec;
++                      if (!timespec_inject_offset_valid(&ts))
++                              return -EINVAL;
++
++              } else {
++                      if (!timeval_inject_offset_valid(&txc->time))
++                              return -EINVAL;
++              }
+       }
+       /*
+-- 
+1.9.1