linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for John Stultz <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: hpa@zytor.com, sasha.levin@oracle.com, prarit@redhat.com,
	tglx@linutronix.de, john.stultz@linaro.org, mingo@kernel.org,
	kay@vrfy.org, linux-kernel@vger.kernel.org,
	dh.herrmann@gmail.com, richardcochran@gmail.com,
	harald@redhat.com
Subject: [tip:timers/urgent] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO
Date: Fri, 22 Jan 2016 03:06:47 -0800	[thread overview]
Message-ID: <tip-dd4e17ab704269bce71402285f5e8b9ac24b1eff@git.kernel.org> (raw)
In-Reply-To: <1453417415-19110-2-git-send-email-john.stultz@linaro.org>

Commit-ID:  dd4e17ab704269bce71402285f5e8b9ac24b1eff
Gitweb:     http://git.kernel.org/tip/dd4e17ab704269bce71402285f5e8b9ac24b1eff
Author:     John Stultz <john.stultz@linaro.org>
AuthorDate: Thu, 21 Jan 2016 15:03:34 -0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 22 Jan 2016 12:01:42 +0100

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>
---
 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 36f2ca0..6df8927 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -685,8 +685,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;
+		}
 	}
 
 	/*

  parent reply	other threads:[~2016-01-22 11:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-21 23:03 [PATCH 0/2] Fix for ADJ_SETOFFSET w/ ADJ_NANO John Stultz
2016-01-21 23:03 ` [PATCH 1/2] ntp: Fix ADJ_SETOFFSET being used " John Stultz
2016-01-22 11:06   ` David Herrmann
2016-01-22 11:06   ` tip-bot for John Stultz [this message]
2016-01-21 23:03 ` [PATCH 2/2] kselftests: timers: Add adjtimex SETOFFSET validity tests John Stultz
2016-01-26 15:39   ` [tip:timers/urgent] " tip-bot for John Stultz
2016-01-21 23:16 ` [PATCH 0/2] Fix for ADJ_SETOFFSET w/ ADJ_NANO Shuah Khan
2016-01-22  7:54   ` Thomas Gleixner
2016-01-22 14:56     ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-dd4e17ab704269bce71402285f5e8b9ac24b1eff@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=dh.herrmann@gmail.com \
    --cc=harald@redhat.com \
    --cc=hpa@zytor.com \
    --cc=john.stultz@linaro.org \
    --cc=kay@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=prarit@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=sasha.levin@oracle.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).