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) {