diff options
author | John Stultz <john.stultz@linaro.org> | 2016-01-21 18:03:34 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-01-22 06:01:42 -0500 |
commit | dd4e17ab704269bce71402285f5e8b9ac24b1eff (patch) | |
tree | f2db2bd33dd1c38ddab21d029c216466ae54d4be /kernel | |
parent | 51cbb5242a41700a3f250ecfb48dcfb7e4375ea4 (diff) |
ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO
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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/time/ntp.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 36f2ca09aa5e..6df8927c58a5 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c | |||
@@ -685,8 +685,18 @@ int ntp_validate_timex(struct timex *txc) | |||
685 | if (!capable(CAP_SYS_TIME)) | 685 | if (!capable(CAP_SYS_TIME)) |
686 | return -EPERM; | 686 | return -EPERM; |
687 | 687 | ||
688 | if (!timeval_inject_offset_valid(&txc->time)) | 688 | if (txc->modes & ADJ_NANO) { |
689 | return -EINVAL; | 689 | struct timespec ts; |
690 | |||
691 | ts.tv_sec = txc->time.tv_sec; | ||
692 | ts.tv_nsec = txc->time.tv_usec; | ||
693 | if (!timespec_inject_offset_valid(&ts)) | ||
694 | return -EINVAL; | ||
695 | |||
696 | } else { | ||
697 | if (!timeval_inject_offset_valid(&txc->time)) | ||
698 | return -EINVAL; | ||
699 | } | ||
690 | } | 700 | } |
691 | 701 | ||
692 | /* | 702 | /* |