From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbcBLJz1 (ORCPT ); Fri, 12 Feb 2016 04:55:27 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34237 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751741AbcBLJzR (ORCPT ); Fri, 12 Feb 2016 04:55:17 -0500 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 v2c 4/8] fs: cifs: Make cnvrtDosUnixTm() y2038 safe Date: Fri, 12 Feb 2016 01:52:49 -0800 Message-Id: <1455270773-3249-5-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455270773-3249-1-git-send-email-deepa.kernel@gmail.com> References: <20160212092153.GA2368@deepa-ubuntu> <1455270773-3249-1-git-send-email-deepa.kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 api's 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, where everyone uses the theoretical max. 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 bf1b52e..ecbb7162 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -963,7 +963,8 @@ static const int total_days_of_prev_months[] = { struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) { struct timespec64 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; @@ -974,7 +975,7 @@ struct timespec64 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) -- 1.9.1