From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751308AbcFASxh (ORCPT ); Wed, 1 Jun 2016 14:53:37 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33764 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076AbcFASxf (ORCPT ); Wed, 1 Jun 2016 14:53:35 -0400 From: John Stultz To: lkml Cc: John Stultz , Mika Westerberg , Baolin Wang , Thomas Gleixner , Shuah Khan , Arnd Bergmann , Ingo Molnar , Richard Cochran , Prarit Bhargava Subject: [PATCH 1/2 v2] time: Fix problematic change in settimeofday error checking Date: Wed, 1 Jun 2016 11:53:26 -0700 Message-Id: <1464807207-16530-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1464807207-16530-1-git-send-email-john.stultz@linaro.org> References: <1464807207-16530-1-git-send-email-john.stultz@linaro.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 86d3473224b0 ("time: Introduce do_sys_settimeofday64()") some of the checking for a valid timeval was subtley changed which caused -EINVAL to be returned whenever the timeval was null. However, it is possible to set the timezone data while specifying a NULL timeval, which is usually done to handle systems where the RTC keeps local time instead of UTC. Thus the patch causes such systems to have the time incorrectly set. This patch addresses the issue by handling the error conditionals in the same way as was done previously. Cc: Mika Westerberg Cc: Baolin Wang Cc: Thomas Gleixner Cc: Shuah Khan Cc: Arnd Bergmann Cc: Ingo Molnar Cc: Richard Cochran Cc: Prarit Bhargava Tested-by: Mika Westerberg Reported-by: Mika Westerberg Signed-off-by: John Stultz --- v2: Add logic simplification from Dima Stepanov include/linux/timekeeping.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 37dbacf..816b754 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -21,6 +21,9 @@ static inline int do_sys_settimeofday(const struct timespec *tv, struct timespec64 ts64; if (!tv) + return do_sys_settimeofday64(NULL, tz); + + if (!timespec_valid(tv)) return -EINVAL; ts64 = timespec_to_timespec64(*tv); -- 1.9.1