From patchwork Tue Jun 19 15:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139178 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5381480lji; Tue, 19 Jun 2018 09:00:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLoMFXBOX27Pgd4NdXShIxk/1YslRF77vnZ/zKQb3l08aaFgpVjroMQFl0n7IAfXIl7SSUk X-Received: by 2002:a17:902:aa95:: with SMTP id d21-v6mr13972083plr.114.1529424017829; Tue, 19 Jun 2018 09:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529424017; cv=none; d=google.com; s=arc-20160816; b=dvP/qiSWpn1tyzuyKX+ZAyJfKVMiSxZWt3ffTGfAsbn1+fO3wiI1gokq+Umc7fEreP VUKCjUlty1HUh/hqASiGMiOvF9GWNhp9K2m7DQIAMI4HlMuBb+Bliub5mhBzKeLbEwhT QlHR3Sg2KcO2yNLXBJAV7N7/emawMTvSUw5z5Z+KqDswBdLzFdrhMWC+N2xVP9DEw/qk z+9o5kZqDHoOeXduVxn5UDMEhI2l+rIPAMONRsxe0MvySRPOgd6C2xr0FGHLEfKwjzlY hUfhn4JdO+FKQsXbLJe6El1HdSAbMGrKz4TTZ59jt7v8jib2TfyMRZCHYMpnnWWvNrNf Dlhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KC4eOmwrGt7T9lRi/b5Nt6Wc+07cXjQ00AVkoZ9NdNo=; b=gfjFfXG4zqGXOHESEVOpzPaTM93S8hWkUhMoaP8dJj6xQxa0xGIig1H7FxL048RP2o BFU9+8RJLQUhSqeApBBr9mSyXz0H487/EeK9b4r+zbpkwYFuGVyx4rfIC2TJza3ntdRa o8Vlgq43JD3bkGcpyLJfb6yfXfWJmxDcCt8I7TEYKewkHxlh2KWzxR27Qg8LSNFhZT5f ZYAmkUskpdgbGIZsS5DO+FKhDfxMpamIuFc6pxLAq+OMxXvgZrZmXZvzScEGrRmtnKgp 0ZT7TcqDvWuC0tu31EntffSfM7tqdODkOaT6UBnSHwRhrLuykKUqgIcDicqOLo6FzzpA Vv8g== 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 t9-v6si16504pgn.559.2018.06.19.09.00.17; Tue, 19 Jun 2018 09:00:17 -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 S966929AbeFSQAP (ORCPT + 30 others); Tue, 19 Jun 2018 12:00:15 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:42101 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966263AbeFSQAA (ORCPT ); Tue, 19 Jun 2018 12:00:00 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MPrBi-1faH7m1TJC-0052b7; Tue, 19 Jun 2018 17:59:32 +0200 From: Arnd Bergmann To: David Woodhouse Cc: Arnd Bergmann , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] jffs2: use unsigned 32-bit timstamps consistently Date: Tue, 19 Jun 2018 17:59:04 +0200 Message-Id: <20180619155925.4107498-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180619155925.4107498-1-arnd@arndb.de> References: <20180619155925.4107498-1-arnd@arndb.de> X-Provags-ID: V03:K1:In2LSs2gpZ6AWdNNz8wswR1amcrtt1fvcMaLH4XrQYVXOTjCte5 W0zgt3tCHO2KTSW6qtCP6bZXGM9gX1a2EKA8ViknC2A3TZSf+90vpg3slG9PLATLCN8ZNSN VRA54wjzBWp+fAY7OExnsjqXlVymv55BhjQ3nTHxhWj4fyH50jOTIjZGOC8RFtIqfeisk60 BAlQQKHVATAM4wECPv0bg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qB1l/bvs9X0=:nFq66kTEoAr7Pv3OGwTMGc AtJzjyBkBLLG6qTI/vPrhC+0odb82wOdT65HJ2gsJ+PqoD8WJF7WRXyRsPmDDK+l3UYXYFyB9 X6sJgPvfLdvzLgbjudavfxeBb1MFniBAWqz53ePxTX7Fd1tJI186+wZTmychcIlAo9mwzEwUJ PqNwOiW+FfFPjwmeAXnD2OepGfXXHKK4I9J3k1c/T+fxoUGbqJ8qbMdbsON3UFiDUusyZD6Qg o9Ua1ot96uKncvI0994XVU9bsbuhNRVHh4J/N6AFRER/w5E6dANWp4FqgGUmt5QEZKikMfBTr /aQS/bIBcnS/UN0v7E7dmYsvd7Ozal4E7Xhmb7sRSJHHrsJTyM9uJeFmBM2URvm1UEfhxgsWY naLUf0vPRwtPcEypwjBOhAqmMC5D+bUeVS42DVxAPlnXDxdLyjN1PTMrG7QOcp1wWFOf10szf k2/9kB3BIkn/s/zGJ/m4F6tBTGg78ssTaLeLa79g8lm410J67wOjDmzIwiBWsi+xaDwZAEHg0 6tvBBRg8w+vLgCPmkPB8ElxV/Qg/Cc25SQ4TmQODQyuWOdrMp4G27mYyUiu3FEkC1SLaA40gj XoxAIfKJ5cZFsB8GMqZHsi3CifqvEqLQziP8etMZwbxz7O7XkDeIoboj7NcUu1/UJ1RFk8YnV 2Db1UDFkzCpumh3+pSEV6ablVQC+ChNil26U77DWt7aaRo0A+HiwJL2kuI4qxCbgcq6Q= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Most users of jffs2 are 32-bit systems that traditionally only support timestamps using a 32-bit signed time_t, in the range from years 1902 to 2038. On 64-bit systems, jffs2 however interpreted the same timestamps as unsigned values, reading back negative times (before 1970) as times between 2038 and 2106. Now that Linux supports 64-bit inode timestamps even on 32-bit systems, let's use the second interpretation everywhere to allow jffs2 to be used on 32-bit systems beyond 2038 without a fundamental change to the inode format. This has a slight risk of regressions, when existing files with timestamps before 1970 are present in file system images and are now interpreted as future time stamps. I considered moving the wraparound point a bit, e.g. to 1960, in order to deal with timestamps that ended up on Dec 31, 1969 due to incorrect timezone handling. However, this would complicate the implementation unnecessarily, so I went with the simplest possible method of extending the timestamps. Writing files with timestamps before 1970 or after 2106 now results in those times being clamped in the file system. Signed-off-by: Arnd Bergmann --- fs/jffs2/os-linux.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.9.0 diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index acbe1f722f2d..a2dbbb3f4c74 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h @@ -31,13 +31,13 @@ struct kvec; #define JFFS2_F_I_GID(f) (i_gid_read(OFNI_EDONI_2SFFJ(f))) #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev) -#define ITIME(sec) ((struct timespec64){(int32_t)sec, 0}) -#define JFFS2_NOW() (ktime_get_real_seconds()) -#define I_SEC(tv) ((tv).tv_sec) -#define JFFS2_F_I_CTIME(f) (OFNI_EDONI_2SFFJ(f)->i_ctime.tv_sec) -#define JFFS2_F_I_MTIME(f) (OFNI_EDONI_2SFFJ(f)->i_mtime.tv_sec) -#define JFFS2_F_I_ATIME(f) (OFNI_EDONI_2SFFJ(f)->i_atime.tv_sec) - +#define JFFS2_CLAMP_TIME(t) ((uint32_t)clamp_t(time64_t, (t), 0, U32_MAX)) +#define ITIME(sec) ((struct timespec64){sec, 0}) +#define JFFS2_NOW() JFFS2_CLAMP_TIME(ktime_get_real_seconds()) +#define I_SEC(tv) JFFS2_CLAMP_TIME((tv).tv_sec) +#define JFFS2_F_I_CTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_ctime) +#define JFFS2_F_I_MTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_mtime) +#define JFFS2_F_I_ATIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_atime) #define sleep_on_spinunlock(wq, s) \ do { \ DECLARE_WAITQUEUE(__wait, current); \