From patchwork Tue Jun 19 16:02:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139181 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5384507lji; Tue, 19 Jun 2018 09:02:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKFVyHHBHgcVLtddwg7fOnL61X1BSTNiwBwLoCLReiixXO5X5WV+2ahmka4z8NLlFJO6DU4 X-Received: by 2002:a63:3c07:: with SMTP id j7-v6mr15240877pga.440.1529424157501; Tue, 19 Jun 2018 09:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529424157; cv=none; d=google.com; s=arc-20160816; b=N/a25+23m3tM7IdRluLZVVQxH8dJi8rQlZgkXcwLAqY+Uw5Yp/I+V+gPi7SL0BVVkI PEEardMUeesCj0WNJJOLatvn/hoGMw11K4oJoS7cOfdJ2QSnMtgSmIM1Wg6El4XT49t7 fhjMznFPFXNsJTBnfZTxNUi3pe7s0H8Vfw3O8ETdMqoIkkGBoFUhIkp8Lf0MB9iaGqZH rhDwijr8GKBWAwT5+90ybnj3ww2+WrZqb0s2HUzXoT2cHtaWUrMLGfIn4JOG+03Mh/4K o3Dt0Us+Sjm13aSxlwcWM1QdGla9Rf//ejj1QfNvURPOxV8rOphUzu60gEwlD2Kh/eaw 1Kyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=I6lEjaheLtYZhsYhJSymWT7bHfh2P77xYxUBE+snoyA=; b=X7JYUMs+rGPdbBavlNgcHct6VcEMBo2A6sJ2Pck6qI2N5D7j+Ho/0GCgQoD4hoqv0n xQkL+T7t44PxvQsR/ItohYX2FsVEDaVAYIvr4/eWZ/rtxkC+TWrGbz5m4NjinUMiYmfP kSwUqVM2HqwINZ226Qlb82fOe0XidE+eQAe4YaF+vyunhRK2XMC3W1frdM3lE07Dx2yv bNcCuMID4VxcXB3agoOUm2YtdG9sc2TV1/S0caoGuNKFVKeHVIfv6oR1k1D835edjyhy XlKwjOm4R2ltwtslOnJFzHht0xdNVsZCKfGvH/8PgeU/kiWT3LY4dReRcNEwj2h+z40p sQaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16-v6si23102pfk.350.2018.06.19.09.02.37; Tue, 19 Jun 2018 09:02:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966864AbeFSQCf (ORCPT + 30 others); Tue, 19 Jun 2018 12:02:35 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:48737 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966267AbeFSQCd (ORCPT ); Tue, 19 Jun 2018 12:02:33 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0MUjoe-1fhSBy3r36-00Y8zn; Tue, 19 Jun 2018 18:02:27 +0200 From: Arnd Bergmann To: Al Viro , Andrew Morton Cc: y2038@lists.linaro.org, Arnd Bergmann , Jeff Layton , Jan Kara , Deepa Dinamani , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] hfs: stop using timespec based interfaces Date: Tue, 19 Jun 2018 18:02:07 +0200 Message-Id: <20180619160223.4108556-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:L9t0W1DT5ojYT4b0E/bYnB21OmagDxPdAxoHiNzQAQe6rlRn8lD lOzuko0IJ1RLmW4p5Zs3X1JZzPcvsvIK/DGmQLKT19Y0ag4Lc9IZBbvnnvrPxzi/xVUE7gT 9y5z3svGqto0Yj2KA529DaWyAWiEeB6eEUpahFJwIiLsYXgKBkNa3Zf+d9w0LZyBTaYONeq ejUpD0cOd8z2pu9hbYTMA== X-UI-Out-Filterresults: notjunk:1; V01:K0:GboANqIifc0=:mfS9Z9MRa2lqf4ywrfyYIh OftX/kdNYHAoDduyF8+CH9gIyb5cb+uvY7C0B43czLf4KPpg5EymBPMgIndIZMFzB2XlySTHr 6MzX1kRZt8xX9VkMaCqhjrpxDfh4mK05w52YDErui7eV4MJXADMe2kLSOUDqxqN2o9Rbjd5lO a2yt2T6D862sxi2Pdpc0EyBv9od4Me7psRGeivTONffhMvsPR+Gm28h7+1wEF2mQHMqPgFmTb S3K3YhJeoGYzSISs6YTAL+SIPFpBZba1kxrX/WDyeBP2nmaC99PHkQguJUSPUzBr8KBYvBiMw eSfHn7gYB/Gi9OWlzxmbPx09PzFL0v3RPxMUg8JcZ/koz8loa/QWCP3lbNTOdwR9qauwW5a6E yy43NwhBxu7u84yyFeVlhgOO3zz35c7X4MrXd8LLt6FcSe8KxwXwQ/wCAcBOaO1KDQG9DR5AQ FBX3OlfS/s/s/lr2ZbUs8wcewBv0FwcKarB5d9g7ObnDjZKE+NrsvAVgjNzGxlxkYaC6SKFc2 ZRdmDGorBJPbymqPrKamNVLfTGGswt36LsOYMcMR+KGx73Y6zQIwDcS2X5pSqNESbXXKaQDe9 Lq3pkbHzHy2Hej/UEVtyT8VmFhUg9OyKiUGKRtJiSZRUalx6JB0D/wZHxyMKQ+r7zonScOceY HcUdQIN6GXRdFL1d2v8dSNTWFIQnqCuTvr5aPzNzREvMTp/Q/OXHwOelN0Hvq3uOnyyI= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The native HFS timestamps overflow in year 2040, two years after the Unix y2038 overflow. However, the way that the conversion between on-disk timestamps and in-kernel timestamps was implemented, 64-bit machines actually ended up converting negative UTC timestamps (1902 through 1969) into times between 2038 and 2106. Rather than making all machines faithfully represent timestamps in the ancient past but break after 2040, this changes the file system to always use the unsigned UTC interpretation, reading back times between 1970 and 2106. Signed-off-by: Arnd Bergmann --- fs/hfs/hfs_fs.h | 6 ++++-- fs/hfs/inode.c | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) -- 2.9.0 Reviewed-by: Ernesto A. Fernández diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index 6d0783e2e276..ff432931a5b1 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h @@ -245,6 +245,8 @@ extern void hfs_mark_mdb_dirty(struct super_block *sb); * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970 * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904 * + * We treat all timestamps before 1970 as times after 2038, so this + * actually works until year 2106 */ #define __hfs_u_to_mtime(sec) cpu_to_be32(sec + 2082844800U - sys_tz.tz_minuteswest * 60) #define __hfs_m_to_utime(sec) (be32_to_cpu(sec) - 2082844800U + sys_tz.tz_minuteswest * 60) @@ -252,9 +254,9 @@ extern void hfs_mark_mdb_dirty(struct super_block *sb); #define HFS_I(inode) (container_of(inode, struct hfs_inode_info, vfs_inode)) #define HFS_SB(sb) ((struct hfs_sb_info *)(sb)->s_fs_info) -#define hfs_m_to_utime(time) (struct timespec){ .tv_sec = __hfs_m_to_utime(time) } +#define hfs_m_to_utime(time) (struct timespec64){ .tv_sec = __hfs_m_to_utime(time) } #define hfs_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec) -#define hfs_mtime() __hfs_u_to_mtime(get_seconds()) +#define hfs_mtime() __hfs_u_to_mtime(ktime_get_real_seconds()) static inline const char *hfs_mdb_name(struct super_block *sb) { diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 2a16111d312f..b3309b83371a 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c @@ -351,7 +351,7 @@ static int hfs_read_inode(struct inode *inode, void *data) inode->i_mode &= ~hsb->s_file_umask; inode->i_mode |= S_IFREG; inode->i_ctime = inode->i_atime = inode->i_mtime = - timespec_to_timespec64(hfs_m_to_utime(rec->file.MdDat)); + hfs_m_to_utime(rec->file.MdDat); inode->i_op = &hfs_file_inode_operations; inode->i_fop = &hfs_file_operations; inode->i_mapping->a_ops = &hfs_aops; @@ -362,7 +362,7 @@ static int hfs_read_inode(struct inode *inode, void *data) HFS_I(inode)->fs_blocks = 0; inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask); inode->i_ctime = inode->i_atime = inode->i_mtime = - timespec_to_timespec64(hfs_m_to_utime(rec->dir.MdDat)); + hfs_m_to_utime(rec->dir.MdDat); inode->i_op = &hfs_dir_inode_operations; inode->i_fop = &hfs_dir_operations; break;