From patchwork Wed Dec 18 16:39:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 182012 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp891524ile; Wed, 18 Dec 2019 08:40:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyK69sjYttXqwFw4VJJ2baedizmfgcX1yJVH7Q6C6qDrsZ+3RLp22GoOS/Sl7fRfTXvJVOY X-Received: by 2002:a05:6830:1691:: with SMTP id k17mr3688904otr.282.1576687211250; Wed, 18 Dec 2019 08:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576687211; cv=none; d=google.com; s=arc-20160816; b=sHaa7Q0bRUgpAI3xjZz7V4OQstei1WXN6n9ELrZdxS8yffxtuFM55NfixY+JHFh7Iv ugb90Hafx+uwOqQQGrsPijCj2dDEaCmQXOsjX3u95YpzneKcqsbR4xcPFJrpkiH4kHNk I9gy2cvk65QgLFmZuzq80BNrYzVMJeslljXSl/Zo2bvUE4MiH/YXZ7bKeKZihVQzmN3n KLX2D9l7ufXSJIEVjMOi0+wRPdulAIczO/j1YN4DVvDHCgWUcltYq+SmvlZ6n/CqEInY T/gUwMV93M5fF839+rh5/8PcuR1CDb5QKwq2zwFCZmPK/zp6YkRKx2cFX1w/ySzkNiZY plMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=GyfR8cyHpB78knSR/Y10+dKfRq6q8Q/gmMHJUZwiJrk=; b=sJUdCroepaGAARhSDGLTxgkmi7X9HtIz10+nGnp4zGN3Xqf7KEYwCplxECeCS1dd6G rE70JNm1on94H8txGJZFbv6pagGj0Vnv/eVaDzZHDJRlhesGVDcDL8dHigMoIPFnAlXD PVullF8MXFEfz97BxixWDrXZ7NdP9HUSDwwRBNCmK6piZZDth0rekhGI6WR2a9ud9MfE N7gNJVk0wUrX1FbFwKgV0S6pFg64qSn9B4vMj5dRct8UHu7IaDBLH+iOVhpCfuIB3so9 3DB2+7ULxjAraEocUgKex/QkAXFsXy657n7qNDELVocezWk4+Q5uD0eXXRgZTT2HSu7J 7k+A== 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 q72si501044oic.18.2019.12.18.08.40.10; Wed, 18 Dec 2019 08:40:11 -0800 (PST) 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 S1727592AbfLRQkK (ORCPT + 27 others); Wed, 18 Dec 2019 11:40:10 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:40215 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbfLRQkJ (ORCPT ); Wed, 18 Dec 2019 11:40:09 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MRTIx-1iMu9G3WSb-00NRZ9; Wed, 18 Dec 2019 17:39:55 +0100 From: Arnd Bergmann To: "Darrick J . Wong" , linux-xfs@vger.kernel.org Cc: y2038@lists.linaro.org, Arnd Bergmann , Brian Foster , Eric Sandeen , Allison Collins , Nick Bowler , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] xfs: rename compat_time_t to old_time32_t Date: Wed, 18 Dec 2019 17:39:28 +0100 Message-Id: <20191218163954.296726-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:E9mF7OYDn9JyQwrHLT+pY4Y1q8BDrhiycRQ3Ygb25o5lMFAbgML r8VIN8pCIoF2EG1eS0sqGdFs16ROCCbwJCM4eSC/EYLBG0P6ZOPrM+WDns2LZkHEOt6dKVZ KigR86K6jd1IXB9Is8ld5PoRU9RZXPkHIF0Ikm07i5N+v7aolUwAq5o8tcWHEe2Aa88Ttmy llvpZ3Q1tHfVjtUL7sAfw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:7cATP4CSdSk=:f9D6xz2FFGd7zqBrEqzNNr 25DzUk6VbJWMouHADDk631BIoq1VL5PSh7hi6MN7wfep+gWhhjEucBFmXuR2bO/5OCMvY4mta vqgKF5AmsMkxvawUCqaQx9jqlJYt+V0c40DieoYHeHf9vAficZdjykAMQi1lEz7IsTNnfqKFC /TMI42qGT8keVFBCOH12cYI6rMio/a0LVhxBntLzfQbCqgPdqzc2+v0ZyE/PZ7kHc204eXCmH bVIMh9B04C8NF1hVACl+DoJt9N2f0tWqd7CqzDkzS+BMWZVzCzr09i4m55OonYvDPGoegMKBm ZS7rWzAqtE1AITyw5o6qk/cphSQaBc/7tQzq7UnsXkgCCo9kZsno4XJdeh5+hnkIlX2Ob4wJX RajGiL1S3Kv35a3gUDWFM8zdebH4mahgIsiZGUIkOKeiBHfbiL1G9VyGq0QSTbRnSHM5x+SQi mHVSlXEaCQ39FQVNDnBpUJRRlssjqUHB9ShEY3V8+j19mYM0hnRGqAShlC+fo3QJXfDe4CGlM TfhaUyhamZXOXWxHWrFajja0AaRBC3L0vLcbJE4hS5kn1BGLng2eLIdq3gLwR457YQKuZh04O D7x6Wbf7HocsfpQu2rOdNz9uV3KHehT/U7FnUHY7FcNNXKARfZgRf8GOHj/zc6teMnBwp1k9o Ngk6ivNWG315zPJL7eah7wniA6dIDSAQXeXMgf6p5/QOWfpB5l+vV6k/lp8gpQ6mLSXyIKiAS B0NPEgoYzzGoK1y+rI4p/pShuZcq0fMxeraEw/VyuYarTKmEP3YlNUnzzkYY2A37KPWbwOTBW v4KERGsd9uBcow2SO2fhq7ww64iL5AdyKwz7i1X0lQhBkxO8+1QRZjn7l5nQyxZFmQpH3fTxd fVGYeDs4N4d/GOxBRhYQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The compat_time_t type has been removed everywhere else, as most users rely on old_time32_t for both native and compat mode handling of 32-bit time_t. Remove the last one in xfs. Reviewed-by: Darrick J. Wong Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_ioctl32.c | 2 +- fs/xfs/xfs_ioctl32.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 Reviewed-by: Christoph Hellwig diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index c4c4f09113d3..a49bd80b2c3b 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -107,7 +107,7 @@ xfs_ioctl32_bstime_copyin( xfs_bstime_t *bstime, compat_xfs_bstime_t __user *bstime32) { - compat_time_t sec32; /* tv_sec differs on 64 vs. 32 */ + old_time32_t sec32; /* tv_sec differs on 64 vs. 32 */ if (get_user(sec32, &bstime32->tv_sec) || get_user(bstime->tv_nsec, &bstime32->tv_nsec)) diff --git a/fs/xfs/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h index 8c7743cd490e..053de7d894cd 100644 --- a/fs/xfs/xfs_ioctl32.h +++ b/fs/xfs/xfs_ioctl32.h @@ -32,7 +32,7 @@ #endif typedef struct compat_xfs_bstime { - compat_time_t tv_sec; /* seconds */ + old_time32_t tv_sec; /* seconds */ __s32 tv_nsec; /* and nanoseconds */ } compat_xfs_bstime_t; From patchwork Wed Dec 18 16:39:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 182013 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp891702ile; Wed, 18 Dec 2019 08:40:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwVPdFWP3wVSj7/hcOVtjGikyHBDLS3MF15umw4+GW8Rp03eLA1IvMB9lLyGkMgpQZCJ8uc X-Received: by 2002:a05:6830:1f89:: with SMTP id v9mr3419641otr.90.1576687218666; Wed, 18 Dec 2019 08:40:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576687218; cv=none; d=google.com; s=arc-20160816; b=AvRerew+uG42FQ+WL8vBaGkPWGtGxideRPO+VKKYX7nNUWDEXwQxN+RhJRJr7fw1HB aWy9aLne7yIsBIPdJi+1W5o6vJL2TZZ35OaWHMrXwwp/qcOLAIelfN3HYAx9WzgWGQwr QvylOp2hCbua7CJ/neG++3lb6sdv+C0+EcTsOOLoz6PuFH5vf0y6yQHtVQQ/YcxjHiB1 7/ipcnYhVtHH/+4TNX6wumVbmd7Gt31WItWUSkX1xFpKIypVf8DqWgS2zsqatJOn0C9H QgsIqz4GqTWFhwvhMzcZEI5x6hFmwazkmG4Z9zagcelrnrAVmVm1SX7kcl/HadRm/SdW FP6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jKG9sgT0YAtRrC5lXQmd/l+oNtTAeSkGN8ziColU9fI=; b=Ok49Us6UJ2/m/2EHcUJJqZwx9nKP32hcwvkAI7vFzU7uumTw/cf+GUPXPbhBARjWOR rKrRsfo3iJk0oyL56BYNVPR0WC7zGaUJbPzPyvTAa1MN5v5rd6Iwaj7Ka7GG0jM5KIlz oGnJMSL2ukpTEF6XGZpyzPycuF6Su5cmgsKp2DmwNsJpWIxat/I3FVvbawpCuSjzAxKW PBDssO+ZUtwMqqZu1zb8omj/2x00CYsnIklu5uK877FKw3Nz3kqy+Qd71vA40GPWuYWY 6Y8qJTslyNwIIkzwf1goMUNId8E59UcmDwYvHDVmdLwf85DOhnmZSrE7uyhZZY2G0Ls1 cREQ== 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 q72si501044oic.18.2019.12.18.08.40.18; Wed, 18 Dec 2019 08:40:18 -0800 (PST) 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 S1727610AbfLRQkR (ORCPT + 27 others); Wed, 18 Dec 2019 11:40:17 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:44199 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727124AbfLRQkQ (ORCPT ); Wed, 18 Dec 2019 11:40:16 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MUGqT-1iGuOr0t6J-00RLZB; Wed, 18 Dec 2019 17:40:06 +0100 From: Arnd Bergmann To: "Darrick J . Wong" , linux-xfs@vger.kernel.org Cc: y2038@lists.linaro.org, Arnd Bergmann , Brian Foster , Dave Chinner , Allison Collins , Jan Kara , Eric Sandeen , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] xfs: disallow broken ioctls without compat-32-bit-time Date: Wed, 18 Dec 2019 17:39:29 +0100 Message-Id: <20191218163954.296726-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191218163954.296726-1-arnd@arndb.de> References: <20191218163954.296726-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:6ujAzFNzbSvWONOGFgSWinycKZWnfNnaCJ6HIW30mi/PzDQi6Wu hKOaMDeT4IWEcnmQSowIe92SThixIKCnshY2b1DvLkb9cwh/JBIhP6ELzY+IEBfeaBlBnvG HG/9w0pt+nFUcJUliGN/drBqfYUb9AK8V0Z8lDB4YEIiaUW8qvmH2nOUBipIWTIT+YULKl0 DLu+k/jmWAKQFz3vpL/vw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Phie+ptjyJE=:EGVmmJtbEU0+IRu25Koo9X gB6r/Vk3tbNyA1FA2jcJ0DLdt6R2yBk3mg2IZZrji+Z5pUazLPh/KswFMI50Enri0I9nE+ANH 2j1XO9is3USpw973y3vrxgDHzE6W4afEKpdgeNymEdnk1nAWMs0wGgUV7cMdUPnzq7mHSyMpJ +KNVxyeARysnFu5t2x3dzxI8dl/f3SVCUI9lAtLb0O3ZsTzNvlbeT7Kbpuv1HHRhzv4jmosd0 e9o3ImrhDWiP6UpFkFw4nwvqVFZd3IXs+fhlFENkpnc3qbZWkskLWT72/M+k8KG/rcw42UeMF m21DzColmhBoh0Ss6DYmHqPuP2jLEts6isFEdkVTUJzyL8360L9RjsbafGHgVqDc29mSyuarx kszzc7VkEvsuP/1SNOSKWb3Wa4aRTjMMocpjrtUdcjA0/uqpYL/A+OJAPwYeqhEEIPKTkkQcM /U4/BegYQ7scv2xY/ti20LtHp+ZvOZyJVnhAwmeQfXdsNQJnuJ1PAvQ45C7j5HShFVH4viDHn dtzQV9TPOLOzFj8vWBjBgTXWEJyA3z4md+oqaTnVense41w1o+rOyk9tOD57gFqtD3Y4ZQRoT T0DwiqDRmBZ2vNKPllydRgAM+ZBgPf2HMUEgeNd5axSPtvpsd3ixSuyVrpjQ6Lbvh/2DYwpSi ww5O4fRDWUP4VaQKBmtrqbl2+3f5cgjO1+raAj6AWncDatN3qQjC9DphFdTKCdLvgbOfzm+4Y wagisEsGvWUe4B5o3B8BXpDstc3oALZP8wCrFBRzI8y4EePxiQztwSQTHI70nGnuWGBoE9mNs M8C07KLky3DBhl31X5ei5Hk9Zm9VB8SHkE6GXpkM+of5Sdc2ZK2rYdMc8XF/+EGyHkwb2h8oF EQJjOtppA7S+gjkCJBRg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When building a kernel that disables support for 32-bit time_t system calls, it also makes sense to disable the old xfs_bstat ioctls completely, as they truncate the timestamps to 32-bit values once the extended times are supported. Any application using these needs to be updated to use the v5 interfaces. Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_ioctl.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 2.20.0 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 7b35d62ede9f..d43582e933a0 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -36,6 +36,7 @@ #include "xfs_reflink.h" #include "xfs_ioctl.h" +#include #include #include @@ -617,6 +618,23 @@ xfs_fsinumbers_fmt( return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp)); } +/* disallow y2038-unsafe ioctls with CONFIG_COMPAT_32BIT_TIME=n */ +static bool xfs_have_compat_bstat_time32(unsigned int cmd) +{ + if (IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)) + return true; + + if (IS_ENABLED(CONFIG_64BIT) && !in_compat_syscall()) + return true; + + if (cmd == XFS_IOC_FSBULKSTAT_SINGLE || + cmd == XFS_IOC_FSBULKSTAT || + cmd == XFS_IOC_SWAPEXT) + return false; + + return true; +} + STATIC int xfs_ioc_fsbulkstat( xfs_mount_t *mp, @@ -637,6 +655,9 @@ xfs_ioc_fsbulkstat( if (!capable(CAP_SYS_ADMIN)) return -EPERM; + if (!xfs_have_compat_bstat_time32(cmd)) + return -EINVAL; + if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; @@ -1815,6 +1836,11 @@ xfs_ioc_swapext( struct fd f, tmp; int error = 0; + if (!xfs_have_compat_bstat_time32(XFS_IOC_SWAPEXT)) { + error = -EINVAL; + goto out; + } + /* Pull information for the target fd */ f = fdget((int)sxp->sx_fdtarget); if (!f.file) { From patchwork Wed Dec 18 16:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 182014 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp896664ile; Wed, 18 Dec 2019 08:44:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy05ZB4TKdsA739Y0CPXUcyrUr3oipMXHHhza3y8bFl07GBjWWuj1yy1uySjUpBuShTyAI6 X-Received: by 2002:a9d:6b12:: with SMTP id g18mr3452346otp.211.1576687492187; Wed, 18 Dec 2019 08:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576687492; cv=none; d=google.com; s=arc-20160816; b=uSij231k3DrEScugcEX9+sVzTrr+dbo5NMhQ7qENCRssyv1i/uNvck2hxcPorms35r jWbFYRP69tR4kbkxaV9cILGqkFJ2qTXKUDkPKCHsxFL6usXTgm++fxi6E7GupP5rKccn CPdbabw4N/puVxknduWPthGXH9IXWxePoXTp5Ht6wSwvHrEXQo1UlHhd6yfmbbe8Y5YQ W74LrzitTRd3Rn1+t9l1RXKmkeWzh1kMdeR7jVnjxyUis86tyIQpmZHek+6s3a/03PL/ pv7kdwU1ggHbP0Nkv9UFeB93NEFZOZWlBA6uCIbx/yyc2xJU7n1NFGO3XQeGztZG3nzk qHWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=KCL/YYhj5nIeuo60iPqIovleteETBEpT286F0Bopugg=; b=jLQL6UuzRqYCVdkj0LL3gYdBdOByJ/tVUhIT5ah9VYFGi96SB9SZrqe6/AKgGR7/Cy PDUYhtSPJburzRPQrJtSwlc7DEmQBcAhamAjuAR3POPY7GclxIitu6/XBA911IMIDo2S Cs1Z3PXo6v1ZtLBNT3xL2FlRNX5dYOedb7Qi0/VNfwLweqSJBRmSq8nOpn2rvqTbxavB 1KRVkxEe5QteumU4/FgVeJLQ+sbd9W9I0Ibd2kYM7Fx8L9Tlci0QL+dQi14vgb7HK2qw V7+No78oRIcFdCyH1kbYF1vzuwLU3k9/xgBrY2ulyDbZ6K5y2U5WP3TICWgZqPiv6lq6 oYjw== 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 n9si1664644ota.103.2019.12.18.08.44.51; Wed, 18 Dec 2019 08:44:52 -0800 (PST) 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 S1727598AbfLRQou (ORCPT + 27 others); Wed, 18 Dec 2019 11:44:50 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:35725 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727215AbfLRQos (ORCPT ); Wed, 18 Dec 2019 11:44:48 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MGgRW-1iTsus1Nac-00Dsp6; Wed, 18 Dec 2019 17:44:20 +0100 From: Arnd Bergmann To: "Darrick J . Wong" , linux-xfs@vger.kernel.org Cc: y2038@lists.linaro.org, Arnd Bergmann , Brian Foster , Carlos Maiolino , Pavel Reichl , Eric Sandeen , Tetsuo Handa , Dave Chinner , Allison Collins , Jan Kara , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] xfs: quota: move to time64_t interfaces Date: Wed, 18 Dec 2019 17:44:05 +0100 Message-Id: <20191218164418.463467-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191218163954.296726-1-arnd@arndb.de> References: <20191218163954.296726-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:FUskByiXnCTH70Q8n4XCuCHT4CPOpZnVwrXf6WYJO0e75Nr0PkI /3qYAc9i1Gb0z3DV7SD6P0CowGHqfFUAgc1InUWAjgphQascqxFczuBbwL/GN7Z76TUNqnK yv7bOtCBDc+pBvCXVUXOZ3Ig3NsqRZn6fRK7lkW3QFrj4Wuf8Xf2gp1UrycHD7XJ5MQsQ8C StzNKoNY4xo73FADLxmUA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:CJHPKKZvaj8=:951edUD5nPzOwVPTUhUzTo Na8wsKech0H1SPSyDKfyESXK+qPEGA6OnlRj0aHs5dOX3SoOLrUqx8HzJQ6aglzju7+HIncJT yBRJgnGP7JRUgHk2tksC0ucChGYjSUJqsPkbFrDlXo18m5COvHH9u6mVbSBVCGpgjLHGZyyDE rLcVEiz+OWpFFSFXQdTlNYAm4gFYn2Mj0fvk/s/82K7He1tfA+JlL4WJNq4Vpnzy+ZcYDZpCv 9eSZ+gmFRGhWXeTc+6RUVeJ5cDSk0K2DPSb8KSnCW5GvqSucWZWSz6CDKEOPtsVI89k8AW8h1 Hy2WhVUpuaKGbWcqUs3OAmBtHqNnSOP5BMsE9u4E553ADYtzFgzRnQM4MCWcR/L+R59lgStGg JI0F0C29gdeTnrGRKWpaj7Gv9tW5LeQPGRSlqOovqnJbSOSRV6ZwAs/cQSmn4E9r/78ZYOrff Yu7ooH71Xb18C0F9KF/kJrZPVeapR4OnXCVRzZgdDoFeynb62+5TpICCNl+ISo/A6S5so2vs7 WKXoR7fWfHUlPqNryVYikAVwLrIRNDKZ44vVwuAjDCfIpZZye+rw+0wjMrnI93MpAOmoy2P+/ V0dH7JFrIWu6rVPhdMDLrKV/UasnYN7sLDmdw+Vexi7CTbS5s9gRZpeazWHLC6RlYcrmdiv0o 1zAHJrJqaVlGfqldsCksKwh0i6OnEaoBfWSnZeP1OCljlz3gbm2Cce2PIsXD1uSFkeq3beX7R /zx/jI4DDP1d4MUr/kiojBi0h4qOzEE+psQzHOLYVBypfxwAkD+pVLiqehJ/gvmM44bhzkObA QcyKcWjd71X3+kXy7nZYqn2DsoSfhSD93OWyCbRmau7YIpcm4+8h7VKgty1JAxfMFAa1778bp 1gxy1cBGfoEw15O0qs9w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a preparation for removing the 32-bit time_t type and all associated interfaces, change xfs to use time64_t and ktime_get_real_seconds() for the quota housekeeping. This avoids one difference between 32-bit and 64-bit kernels, raising the theoretical limit for the quota grace period to year 2106 on 32-bit instead of year 2038. Note that common user space tools using the XFS quotactl interface instead of the generic one still use the y2038 dates. To fix quotas properly, both the on-disk format and user space still need to be changed. Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_dquot.c | 6 +++--- fs/xfs/xfs_qm.h | 6 +++--- fs/xfs/xfs_quotaops.c | 6 +++--- fs/xfs/xfs_trans_dquot.c | 8 +++++--- 4 files changed, 14 insertions(+), 12 deletions(-) -- 2.20.0 diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 2bff21ca9d78..9cfd3209f52b 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -137,7 +137,7 @@ xfs_qm_adjust_dqtimers( (d->d_blk_hardlimit && (be64_to_cpu(d->d_bcount) > be64_to_cpu(d->d_blk_hardlimit)))) { - d->d_btimer = cpu_to_be32(get_seconds() + + d->d_btimer = cpu_to_be32(ktime_get_real_seconds() + mp->m_quotainfo->qi_btimelimit); } else { d->d_bwarns = 0; @@ -160,7 +160,7 @@ xfs_qm_adjust_dqtimers( (d->d_ino_hardlimit && (be64_to_cpu(d->d_icount) > be64_to_cpu(d->d_ino_hardlimit)))) { - d->d_itimer = cpu_to_be32(get_seconds() + + d->d_itimer = cpu_to_be32(ktime_get_real_seconds() + mp->m_quotainfo->qi_itimelimit); } else { d->d_iwarns = 0; @@ -183,7 +183,7 @@ xfs_qm_adjust_dqtimers( (d->d_rtb_hardlimit && (be64_to_cpu(d->d_rtbcount) > be64_to_cpu(d->d_rtb_hardlimit)))) { - d->d_rtbtimer = cpu_to_be32(get_seconds() + + d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() + mp->m_quotainfo->qi_rtbtimelimit); } else { d->d_rtbwarns = 0; diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 7823af39008b..4e57edca8bce 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -64,9 +64,9 @@ struct xfs_quotainfo { struct xfs_inode *qi_pquotaip; /* project quota inode */ struct list_lru qi_lru; int qi_dquots; - time_t qi_btimelimit; /* limit for blks timer */ - time_t qi_itimelimit; /* limit for inodes timer */ - time_t qi_rtbtimelimit;/* limit for rt blks timer */ + time64_t qi_btimelimit; /* limit for blks timer */ + time64_t qi_itimelimit; /* limit for inodes timer */ + time64_t qi_rtbtimelimit;/* limit for rt blks timer */ xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */ xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */ xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */ diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c index c7de17deeae6..38669e827206 100644 --- a/fs/xfs/xfs_quotaops.c +++ b/fs/xfs/xfs_quotaops.c @@ -37,9 +37,9 @@ xfs_qm_fill_state( tstate->flags |= QCI_SYSFILE; tstate->blocks = ip->i_d.di_nblocks; tstate->nextents = ip->i_d.di_nextents; - tstate->spc_timelimit = q->qi_btimelimit; - tstate->ino_timelimit = q->qi_itimelimit; - tstate->rt_spc_timelimit = q->qi_rtbtimelimit; + tstate->spc_timelimit = (u32)q->qi_btimelimit; + tstate->ino_timelimit = (u32)q->qi_itimelimit; + tstate->rt_spc_timelimit = (u32)q->qi_rtbtimelimit; tstate->spc_warnlimit = q->qi_bwarnlimit; tstate->ino_warnlimit = q->qi_iwarnlimit; tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit; diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index a6fe2d8dc40f..d1b9869bc5fa 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -580,7 +580,7 @@ xfs_trans_dqresv( { xfs_qcnt_t hardlimit; xfs_qcnt_t softlimit; - time_t timer; + time64_t timer; xfs_qwarncnt_t warns; xfs_qwarncnt_t warnlimit; xfs_qcnt_t total_count; @@ -635,7 +635,8 @@ xfs_trans_dqresv( goto error_return; } if (softlimit && total_count > softlimit) { - if ((timer != 0 && get_seconds() > timer) || + if ((timer != 0 && + ktime_get_real_seconds() > timer) || (warns != 0 && warns >= warnlimit)) { xfs_quota_warn(mp, dqp, QUOTA_NL_BSOFTLONGWARN); @@ -662,7 +663,8 @@ xfs_trans_dqresv( goto error_return; } if (softlimit && total_count > softlimit) { - if ((timer != 0 && get_seconds() > timer) || + if ((timer != 0 && + ktime_get_real_seconds() > timer) || (warns != 0 && warns >= warnlimit)) { xfs_quota_warn(mp, dqp, QUOTA_NL_ISOFTLONGWARN);