From patchwork Fri Apr 22 19:03:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 66496 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp885939qge; Fri, 22 Apr 2016 12:03:39 -0700 (PDT) X-Received: by 10.98.9.83 with SMTP id e80mr30893533pfd.34.1461351813703; Fri, 22 Apr 2016 12:03:33 -0700 (PDT) Return-Path: Received: from mail-pa0-x236.google.com (mail-pa0-x236.google.com. [2607:f8b0:400e:c03::236]) by mx.google.com with ESMTPS id 144si8195964pfx.223.2016.04.22.12.03.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2016 12:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c03::236 as permitted sender) client-ip=2607:f8b0:400e:c03::236; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of john.stultz@linaro.org designates 2607:f8b0:400e:c03::236 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-pa0-x236.google.com with SMTP id zm5so42258479pac.0 for ; Fri, 22 Apr 2016 12:03:33 -0700 (PDT) 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=TL60lNJsFfg2+JNqTBWwHnqjoR/ghS37yJxQDrGbLwQ=; b=akyMy/22jSaTI3zoQQeG9Hp8bOyJrL/dvJUsAgj6z/7LOl0jhF6GECtWqPQqKvhSZW Y+dSs5ZQrkSUV0sv8tl+V15eNM1geo9CyRHKVCsi5BDAP1imM8CsG8qCjTTPVJ93j14L Njc8YXiH6MUVO8UAZHD3IPPiYoz+UrzhEcq0M= 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=TL60lNJsFfg2+JNqTBWwHnqjoR/ghS37yJxQDrGbLwQ=; b=ekSe67c7LP+k0vLads/I1husbXYmBYFQFBVGxJsFwkMIl4QIruVG3PtVtR0UC7v4BL fShanXQOztZrC8t3YUIHvavvBVwHp61ug5q5/AqP/cHbpnZnuiVNApIe1And0rTYXdz6 1RfKNMq31SNpmTd4LbLrelP7xxbtgZJeYb/3z9nMhnS6npbYRv1Ls+dLHIaL2YIuIBBO 619d9nfG7gd4I1CsRY25D9U9YVP3hFvtnrjAefq+OO2Aqr7RwYdpzMKwByu+noZeDC+1 5DZEQh7JWKx6qLSAr9GGTnTsmP5Q9LQEWHDUDMAJPt4gpzMkkxRzGMBY+wO2cHSRJTcR RcdQ== X-Gm-Message-State: AOPr4FUDfFrhf2LxEIbphKT+b/r2I1qiixpNVgmJ3XKD4Ax6YjI6VPmRgU9N6HIrwnigwORGihg= X-Received: by 10.66.100.197 with SMTP id fa5mr26427856pab.25.1461351813456; Fri, 22 Apr 2016 12:03:33 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-73-67-244-238.hsd1.or.comcast.net. [73.67.244.238]) by smtp.gmail.com with ESMTPSA id ba9sm11243564pab.24.2016.04.22.12.03.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Apr 2016 12:03:32 -0700 (PDT) From: John Stultz To: lkml Cc: Baolin Wang , Prarit Bhargava , Richard Cochran , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 3/3] time: Introduce do_sys_settimeofday64() Date: Fri, 22 Apr 2016 12:03:27 -0700 Message-Id: <1461351807-12495-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1461351807-12495-1-git-send-email-john.stultz@linaro.org> References: <1461351807-12495-1-git-send-email-john.stultz@linaro.org> From: Baolin Wang The do_sys_settimeofday() function uses a timespec, which is not year 2038 safe on 32bit systems. Thus this patch introduces do_sys_settimeofday64(), which allows us to transition users of do_sys_settimeofday() to using 64bit time types. Cc: Prarit Bhargava Cc: Richard Cochran Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Baolin Wang [jstultz: Include errno-base.h to avoid build issue on some arches] Signed-off-by: John Stultz --- include/linux/timekeeping.h | 17 +++++++++++++++-- kernel/time/time.c | 8 ++++---- 2 files changed, 19 insertions(+), 6 deletions(-) -- 1.9.1 diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 96f37be..37dbacf 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -1,6 +1,8 @@ #ifndef _LINUX_TIMEKEEPING_H #define _LINUX_TIMEKEEPING_H +#include + /* Included from linux/ktime.h */ void timekeeping_init(void); @@ -11,8 +13,19 @@ extern int timekeeping_suspended; */ extern void do_gettimeofday(struct timeval *tv); extern int do_settimeofday64(const struct timespec64 *ts); -extern int do_sys_settimeofday(const struct timespec *tv, - const struct timezone *tz); +extern int do_sys_settimeofday64(const struct timespec64 *tv, + const struct timezone *tz); +static inline int do_sys_settimeofday(const struct timespec *tv, + const struct timezone *tz) +{ + struct timespec64 ts64; + + if (!tv) + return -EINVAL; + + ts64 = timespec_to_timespec64(*tv); + return do_sys_settimeofday64(&ts64, tz); +} /* * Kernel time accessors diff --git a/kernel/time/time.c b/kernel/time/time.c index be115b0..a4064b6 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -160,15 +160,15 @@ static inline void warp_clock(void) * various programs will get confused when the clock gets warped. */ -int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz) +int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz) { static int firsttime = 1; int error = 0; - if (tv && !timespec_valid(tv)) + if (tv && !timespec64_valid(tv)) return -EINVAL; - error = security_settime(tv, tz); + error = security_settime64(tv, tz); if (error) return error; @@ -186,7 +186,7 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz) } } if (tv) - return do_settimeofday(tv); + return do_settimeofday64(tv); return 0; }