From patchwork Thu Jan 21 23:03:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 60105 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp289304lbb; Thu, 21 Jan 2016 15:03:41 -0800 (PST) X-Received: by 10.66.156.134 with SMTP id we6mr64408573pab.92.1453417421431; Thu, 21 Jan 2016 15:03:41 -0800 (PST) Return-Path: Received: from mail-pa0-x231.google.com (mail-pa0-x231.google.com. [2607:f8b0:400e:c03::231]) by mx.google.com with ESMTPS id g15si4876927pfg.147.2016.01.21.15.03.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jan 2016 15:03:41 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c03::231 as permitted sender) client-ip=2607:f8b0:400e:c03::231; Authentication-Results: mx.google.com; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c03::231 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-pa0-x231.google.com with SMTP id cy9so30502208pac.0 for ; Thu, 21 Jan 2016 15:03:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sAxf5Q9skIitMl3xIoO518q2KS0QI2hKmJnOSNFXSFI=; b=QA+odxLlXbzsm3ftEr8GbEe26dG9oT8lAQVFiVYXL/7mq5rQddc6twPnehyGyv2HOi ySQxHWCximR8OZtjpxZ0zJ3yYPoldPG4CCwyiAZB3OA7P7FF1D+rsBoHagUBHdhj+jh1 S3kZdfiTiV5B/G8kqKVQlCAoj5n/7aOlOtM8o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sAxf5Q9skIitMl3xIoO518q2KS0QI2hKmJnOSNFXSFI=; b=gkeg9pK5l5E0LIEv47GhLeliOipJ+bF2dKo0k/Hi8VWuo2Go4SAT+Xowi8hl9O6z6d uihCTA3z25G3p1dsGnhMXeekkxYxSxDIcKnhX8dxOE7/E725E2nZKoxyE5Lz5xnH5BOp X1Ey8cI3OiA3+iWuWmHvraXJvYAWPrOgTG32Hkbytmz+VcIVrlqtSlKRHcnxtebOolXj PJlLQ3cL11o/9nOp5h/b7kt58fHYT8NnJnDe8ZrXFZ+pnkVBZNm48SPI7Mv++dV0c8Au VkYcXNPCxGlehH5Bd4RMUvBqpn5PJB6LFTx6wV7eZnaXmxN2qq8MsoFGb06WTEn2Vw/q 4HNQ== X-Gm-Message-State: AG10YOStBFhBpl3/Y/m/fTXuRLSqXMNAxJEzQairJ939Ah0vXNEbHaC9pYavBY2Mn5KaRtX99SI= X-Received: by 10.67.24.3 with SMTP id ie3mr27610854pad.23.1453417421092; Thu, 21 Jan 2016 15:03:41 -0800 (PST) Return-Path: Received: from localhost.localdomain (c-76-115-103-22.hsd1.or.comcast.net. [76.115.103.22]) by smtp.gmail.com with ESMTPSA id pu3sm4959596pac.9.2016.01.21.15.03.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jan 2016 15:03:40 -0800 (PST) From: John Stultz To: lkml Cc: John Stultz , Sasha Levin , Richard Cochran , Thomas Gleixner , Prarit Bhargava , Harald Hoyer , Kay Sievers , David Herrmann Subject: [PATCH 1/2] ntp: Fix ADJ_SETOFFSET being used w/ ADJ_NANO Date: Thu, 21 Jan 2016 15:03:34 -0800 Message-Id: <1453417415-19110-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453417415-19110-1-git-send-email-john.stultz@linaro.org> References: <1453417415-19110-1-git-send-email-john.stultz@linaro.org> Recently, in commit 37cf4dc3370f ("time: Verify time values in adjtimex ADJ_SETOFFSET to avoid overflow") 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. Cc: Sasha Levin Cc: Richard Cochran Cc: Thomas Gleixner Cc: Prarit Bhargava Cc: Harald Hoyer Cc: Kay Sievers Cc: David Herrmann Reported-by: Harald Hoyer Reported-by: Kay Sievers Signed-off-by: John Stultz --- kernel/time/ntp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 1.9.1 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; + } } /*