From patchwork Fri Feb 12 09:35:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 8289531 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 412819F1C0 for ; Fri, 12 Feb 2016 09:41:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 62652203C1 for ; Fri, 12 Feb 2016 09:41:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 765A2203B7 for ; Fri, 12 Feb 2016 09:41:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751706AbcBLJgn (ORCPT ); Fri, 12 Feb 2016 04:36:43 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34645 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbcBLJgk (ORCPT ); Fri, 12 Feb 2016 04:36:40 -0500 Received: by mail-pa0-f51.google.com with SMTP id fy10so4846744pac.1; Fri, 12 Feb 2016 01:36:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eTkh89O1DbCFLn2742h4RHXMZh3gsIjX0S18Vlk5DFw=; b=jfsp1/CPACAYCGur1zIXGHryPgRyCrmiiyAWhSzU2r9qxOVV1ASdaEFdRfWKSYVc40 vPflEyDcqawReVRTyWUgVgx7bcTCdIWtxi0yWzm4EVa3r33n+2baprv6URm/pyvTn8PO /pmw4Siz1x0zHHklDdZt49uFt//HtR26QWJE3Oizj6R47rTId6KOxr2yPVn8XEfdoUS8 YUUzFpSIotJgix9/IMs6mDK9D9JK2KRLUpi4wjMmkajU2dBsCX0JHqTqRY8MuONvccMQ wD/pU+btRnd9rRCXG1piCqdKhEV/5W139iCvMtj4aS3XC9jFa+SG8jZuS6JhhZsi/RcD jjmA== 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=eTkh89O1DbCFLn2742h4RHXMZh3gsIjX0S18Vlk5DFw=; b=UXF0Euee18QrzR+2xCPOBdMOukaQHGGm1EHKOGtmkRlHVJFYHx5DvAwpYVEkB8tS/y 0lUySexR/+kw0Ab72Ba7XJuVlqKKZLDaWBnygMnP3Mf6R1XRXLXEkQPYqMbxRGYhImsk yY0LnHG049+9BfWNq5HszcctNyl+Of9oVHBWCQHklnqlX1VRHwbyls/yRqc4ag2T2f56 8z6DoZ6GePAyQx1R7sWJ4crGe0GdWXT8JIWr8vV2IW9Yj+7wSLR6GfOV1+bB4BjCTcZf C5JQWDITYu/6Q5quNdjNA7RmTQIXigsgKfI/q2M+w+Hc8RjFL3f6Waed4wAt8PUR1SMg 3W8Q== X-Gm-Message-State: AG10YOTfRXRanBM1PRo6PS1Uz6PiEGDhPf1DqwvitezkzIXL9MXL+T6J9WdqeytMUyuLEA== X-Received: by 10.66.100.129 with SMTP id ey1mr705765pab.100.1455269800207; Fri, 12 Feb 2016 01:36:40 -0800 (PST) Received: from localhost.localdomain ([106.51.31.162]) by smtp.gmail.com with ESMTPSA id g25sm17972250pfg.35.2016.02.12.01.36.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Feb 2016 01:36:39 -0800 (PST) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org Cc: Arnd Bergmann , Dave Chinner , "Theodore Ts'o" , linux-kernel@vger.kernel.org Subject: [RFC v2a 04/12] fs: cifs: Make cnvrtDosUnixTm() y2038 safe Date: Fri, 12 Feb 2016 01:35:58 -0800 Message-Id: <1455269766-2994-5-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455269766-2994-1-git-send-email-deepa.kernel@gmail.com> References: <20160212092153.GA2368@deepa-ubuntu> <1455269766-2994-1-git-send-email-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The seconds calculated from the server(DOS format) cannot be saved in int data type as this cannot save seconds since epoch after the year 2038. Use long long for seconds field in cnvrtDosUnixTm(). This will help represent 64 bit time even on 32 bit systems. Note that even though the theoretical max on DOS times is 2107, its APIs only support until the year 2099. This means we can get away with 32 bit unsigned sec field. But, the sec field uses long long to maintain uniformity in the kernel as the theoretical max is used everywhere else. Signed-off-by: Deepa Dinamani --- fs/cifs/netmisc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index 86bc0e5..52b41bd 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -962,7 +962,8 @@ static const int total_days_of_prev_months[] = { struct vfs_time cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) { struct vfs_time ts; - int sec, min, days, month, year; + long long sec; + int min, days, month, year; u16 date = le16_to_cpu(le_date); u16 time = le16_to_cpu(le_time); SMB_TIME *st = (SMB_TIME *)&time; @@ -973,7 +974,7 @@ struct vfs_time cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) sec = 2 * st->TwoSeconds; min = st->Minutes; if ((sec > 59) || (min > 59)) - cifs_dbg(VFS, "illegal time min %d sec %d\n", min, sec); + cifs_dbg(VFS, "illegal time min %d sec %lld\n", min, sec); sec += (min * 60); sec += 60 * 60 * st->Hours; if (st->Hours > 24)