From patchwork Fri Nov 8 21:32:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178986 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3310866ilf; Fri, 8 Nov 2019 13:33:42 -0800 (PST) X-Google-Smtp-Source: APXvYqxxNBuDo00nrCoZ0sYvZbGLXza+mWAk9LBkA+QQfwvfYFxVSYqMS6FETTd9aRF4kLC/DoUw X-Received: by 2002:a05:6402:148d:: with SMTP id e13mr5726146edv.290.1573248822475; Fri, 08 Nov 2019 13:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248822; cv=none; d=google.com; s=arc-20160816; b=gOoy3qcngT9rZCw9P7FEeDszCtIWO2NlSle41gwfEDcBXp2Xb3tZHKr9cbCT2w74AX 4t1cLjxbgpmhBR50DsH2KuNbj0QNjURF8nnxlMaNj4Dz3zdSYTKPhpv7yZbNslWgBH8y d9fAmY/G70WCmK0gQEP0YtfkE5LlZ+1Q/vR2ixvfAl80RBIjFwkMPnkisAH89koFobC1 I+AEPLrFQAotDrpbvE4bctMGSpoZVHE5fsMFOetfVdHVw9TqdFWaXUCx71prrgtbKEn2 4uloM4a7MYHjBcyQsK2EodSbn7dC/sCs/fDVMHhuArFx+6XbIsxHEgNMNGr82XzD4flX H6Lw== 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=d3kn94vJyi5xurZ0SFwSo+SGQo3eNcFjJw1RuiIPnI0=; b=y3uyVewWKtJKz2Tes/jIcr/ePiqWUDMr3TXri8v/e6XI0/ULfbEliCgqHdg3OxnJ0T BlS51Sc6YAMoWvXjbaRFiObxJQg18tA1pGXb7yQWgWoH1RrWcV6Gt3FAP+tyQMVfpZbB 6HcCw9BssFvP95RD8NatTXiMq2TkjMYb9nTxVRxqcRL4Q4MdaVKIVntvKxF0Lib+c1yT chHelqWeCMmQS/jUUd8qH9iAxOkj2yNeqW4VsmBBMP9akCS0A35gIuA1UCJMklUO1GIb RMCHAqRqpFLn8dk2Dg4DU5ZFGogyIw9NzjBhX6JoJgqCrRqOQGa2FN3F08/AccUu3Dle PrPg== 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 k21si4468896ejc.148.2019.11.08.13.33.42; Fri, 08 Nov 2019 13:33:42 -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 S1732685AbfKHVdk (ORCPT + 26 others); Fri, 8 Nov 2019 16:33:40 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:42255 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731601AbfKHVdk (ORCPT ); Fri, 8 Nov 2019 16:33:40 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MOzCW-1iGzco0Bwa-00PKzo; Fri, 08 Nov 2019 22:33:26 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Valdis Kletnieks , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Valentin Vidic , devel@driverdev.osuosl.org Subject: [PATCH 01/16] staging: exfat: use prandom_u32() for i_generation Date: Fri, 8 Nov 2019 22:32:39 +0100 Message-Id: <20191108213257.3097633-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:0MSwPuOaQAzghrJEDyZlqv05bI/+SpkvfIU+MJ9BeKiWSPaHd0p 392UEHTrotwvsLO4OcIt/xO0Z3OGprQKX5WHtFKLoQAQpDv6I2mmSdje+gQQz74ZSiHGY0F KijxNkEpHfi8XdJMia3y2N6RpdjFbm5OKxME6GlH17dMSMZEG8jO22jb9ol3SgxZaSltt/b vN8t1LsHzkSgZ06ObIKEA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:oLz/LL5df3I=:aBRiyUF0lSDKUtt5Gjjqhy xYbnz9RoFaI1jbfsYk63+qmbpstnTAeqese/D2MfJDQTwJLcosbmet6dHm2Y2Gpctt6tZyasb Bhr6nFPe9HkBTxappYvULm/0UpzYIgfIoxW8ckQ0I8aL51oGwTCkvNucbRoZnj/wswSgOlSbQ GjWfMQFQGusbttCDtzK3ZwhozndLBxXca8ZY1usyNDycBG52rvqlCrG2526j3lriF4AXeJ9Gh vzHmF49hdGwXkqao+mG8gcyhP43N/2pSgNFuMmpyyASRYkELYohIOdIfXTcS6xcsQNyXhnDJi qEedgfwOXmQvuwLS24iB23AmHuSU3KcvqCssypdHni1Zfxp4MXrjn7emneRwS94DhYebw9q3K sdOJCZI6NOvHYQiTFYmrdMnuZeRrVu36nhH8O+xrGq0yNwk/UfIXyWGEg92hka5tIAdymYD9u du0CGF/HkHtQbpdyOxGNqxvLQHON4K1S0gcux63cdOENL+nMJmiKHxXfvZxloRvt6dLeo5XLQ lJ+cy+eklRnJhQXpPs0w1MsZY0FQYbExvxDgxEgW1rJuScpZA8450rwmGSfuIR0kKfPkm3Co/ rXk+z59Y9aHOu96JhZEI2At6n83c5rlB821oHQSjI1U045WyyPsyDd4H46clT5qMYOSpatAql ihzR2AzCw0jsMQYX7hTqKEjTAGTqM+caI5lMwkcIfnJckOsEWyRorU98zrLQmtBGGJ2WV2o+s PYevsMCDYkCC0XIRPm9KGB54XUFkkjLT4Xtt+n5P8G65pFRs9SjJ6F2j//N/I3WvejnHSRpPA kh2fSiEEPVK6jq0xaEBm5MOd58/oEayTLsEJme3KiY+oaRMngbP8kPsf2NJ1tf5MHOVVyw91I tMBd12T9KRLgVow+HOSg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to commit 46c9a946d766 ("shmem: use monotonic time for i_generation") we should not use the deprecated get_seconds() interface for i_generation. prandom_u32() is the replacement used in other file systems. Signed-off-by: Arnd Bergmann --- drivers/staging/exfat/exfat_super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 Acked-by: Valdis Kletnieks diff --git a/drivers/staging/exfat/exfat_super.c b/drivers/staging/exfat/exfat_super.c index 3b2b0ceb7297..da76c607f589 100644 --- a/drivers/staging/exfat/exfat_super.c +++ b/drivers/staging/exfat/exfat_super.c @@ -26,7 +26,7 @@ #include #include #include - +#include #include #include #include @@ -3314,7 +3314,7 @@ static int exfat_fill_inode(struct inode *inode, struct file_id_t *fid) inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; INC_IVERSION(inode); - inode->i_generation = get_seconds(); + inode->i_generation = prandom_u32(); if (info.Attr & ATTR_SUBDIR) { /* directory */ inode->i_generation &= ~1; From patchwork Fri Nov 8 21:32:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178987 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3311096ilf; Fri, 8 Nov 2019 13:33:55 -0800 (PST) X-Google-Smtp-Source: APXvYqx8hNcGnBsKGHlKdyHR3DyPm2F3ZpEJB7ZoXKfMK217v5MIDovJqejFhXPtl3FN68qiQbWq X-Received: by 2002:a17:906:e0d5:: with SMTP id gl21mr10739998ejb.292.1573248835251; Fri, 08 Nov 2019 13:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248835; cv=none; d=google.com; s=arc-20160816; b=QOCeXVBTWyYiPk/Xfa7GmK1gTqv4FtUvQbZrA62ZqkLkvhiYyXdT5DfAdVfOpQRZNd nirDgeYIKD0Tf6w0QqTJqaB2OVyk/NV1XuhwVqvFlGL6Xa09gV/VC4WMayoKL0Q/JQTa Y5ETFf00z0uvw2x+411+Pg+rGtHlIgYkKCLNjSql1a1Dfaxpseh0DF6DG8t4Id6ccCMI bUdD4h0gGYXrSJKnM5ttU7xwoMNTUfHGiV9T9N1CvK2IcPzUkq1UroYo9gLIlxdHOxDb tsRsDDjwziSCViZKM+tz1HJmpdUp8DvOfqHTYyWE5w+MVvTVMnHLiMsFkAED+d+L3GOF Ss+Q== 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=hiZPdEQwSVnPES5BzgB7DrGPJq+0YozuFyAoOABELVY=; b=CyWLLTu8C7kAosa5qdYagzVZZgdXKv9QfbLHlummJbEy/AqbFTBAQoTefAOPELgNRc ZBo2I0ztdhemGBxYLVQTcTkPJujTRYbV7YAgWeZrkOgBnvJxbnWJYzkdHPzI6iADJk4I ZDdiIxCKQJFNfcRAPznYjHs6aK8W3w7GalPUP8ekPaBup5A2/wd/4llrGcAxIK/5io7A +rsZZmEsk3wrqrNnHuct8svlqmCKMEsDeM5zLvu9Zk41C5tfRWkfi7TBx5Wpn+A9DMcb 86eltVOz/JdGmAf+c7CWE+5pkYZ2Bc7ggUR75t67anhlcMdca9dueVEsNxKFFOpTmELk h0eg== 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 i10si4516219ejj.8.2019.11.08.13.33.54; Fri, 08 Nov 2019 13:33:55 -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 S1732788AbfKHVdw (ORCPT + 26 others); Fri, 8 Nov 2019 16:33:52 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:52815 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731765AbfKHVdw (ORCPT ); Fri, 8 Nov 2019 16:33:52 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MSswA-1iLzYt2E18-00UGxO; Fri, 08 Nov 2019 22:33:37 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, OGAWA Hirofumi Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Sergey Senozhatsky , Andrew Morton , Carmeli Tamir , Greg Kroah-Hartman , Thomas Gleixner , Al Viro , Deepa Dinamani Subject: [PATCH 02/16] fat: use prandom_u32() for i_generation Date: Fri, 8 Nov 2019 22:32:40 +0100 Message-Id: <20191108213257.3097633-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:xyMkheBDOQ2yaVVntEHgn9uUv1eZLDi2PHuV/3eFCHO8p5lovZV RSePDEWBDJbgngLzGRALBZfJl5JOc/Jtxuyr7QiT/iBCBbjdZJGTSgC2IvsTsu/G8Wrk8Qp GiN6kRR+nPbTe/wfuUTgyPddaHuqJCxUZ4XE1/4ITyS+2pjP8u0UFcA4cFLt8YYwP57kCQJ fk91hJAfaQeU9TGvmYShw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DJ2s+pQ7k9s=:/y5VLXzDEQnWFAeSQ6xOT6 CQnsEi8h6oR3+uq3G21bQgEahitqAHnJmT2KNTIAE8E657mVB3N+hZQ9MTvbAybhVKnqHNHNR idT/3YENYmr7+Njvqjjc5RlZUQ7KJ/Xv+472f1SMhcd4wTbzZ9Q+ZvYWq2DeXrpC93sVDUloQ I32eSBkZX/7ZdDfCUxAp0B+IIwql1HylbLmE5hP6xhaB/uFKE2x5CE9Ua89bKlPpuSBg0HWki zHAbhuWTY2ZKkVv/X0MMYPM6aKf2kNzBxAAltGfZ+eRS3mu2lwNR9W3LZZEiUUfBB7+iSfVzW /jxxhOSksfm3m7CthVRll/a6vzheR2WY6N5z2p2DsAmenRm83oq8O6BEfhrAjxj0gXmpAzR5w kraqdJ2wHUtKHYL4l5I/PgR4ZwVw6/3tEyql+pwkXSEbvxGyGWxSdpEluEBbekv2jL394ePX+ uMs9A3kzqjXQRDuahnIHfvYhfryebO84fKl/Cf6TpkqZwxIpYkK1ivI8m6E8GXYxLB8d5YhKR MAYuH+Ji89DIFPRilXJPMotaHackTxXkzFWYwbl5fO1Rr0yxPGxDzQq/DS98nCPNLFyKvhFxK HlJSfzSdE58tDYScQrsLPnu7A/z5bKPzaq3SCdjqAFtYaHj0HNAe0dOSSVfXjulvXmrGEpsMX cinqux25sQ19OjeTolQIXEge/FzmqODBKtBdAXBzhY64ukP5DvhJxTWMjNcYsylJhppWeRbmY +qRFjY/JlKmmqmFeFZGMG/qAbOSmXB16SupBJmoVWfFYh5zRUzZUrPMStqqrRK95Z0H5qj/qB g7stPBh+VKB1WFBmPVWW/pvdNqHEn/Zqhh14UaYRUD/jI6qp9qeqL+r6hhd+ITpG67/O+Hsas q+8rrmNsLbzj3POPuP2w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to commit 46c9a946d766 ("shmem: use monotonic time for i_generation") we should not use the deprecated get_seconds() interface for i_generation. prandom_u32() is the replacement used in other file systems. Signed-off-by: Arnd Bergmann --- fs/fat/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.0 diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 5f04c5c810fb..594b05ae16c9 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "fat.h" @@ -521,7 +522,7 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de) inode->i_uid = sbi->options.fs_uid; inode->i_gid = sbi->options.fs_gid; inode_inc_iversion(inode); - inode->i_generation = get_seconds(); + inode->i_generation = prandom_u32(); if ((de->attr & ATTR_DIR) && !IS_FREE(de->name)) { inode->i_generation &= ~1; From patchwork Fri Nov 8 21:32:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178988 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3312046ilf; Fri, 8 Nov 2019 13:34:45 -0800 (PST) X-Google-Smtp-Source: APXvYqzysGy8GzbbwtHSB7mSYBrgeGjKyEbdZuraBGwWWWt+PoJJc4B9uA9uU2jutI3D0JrOqs74 X-Received: by 2002:a17:906:404d:: with SMTP id y13mr8052400ejj.276.1573248885318; Fri, 08 Nov 2019 13:34:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248885; cv=none; d=google.com; s=arc-20160816; b=lG1mP4YYKSWSCOIVa4mygOC7FT4V4ICz6Rob7I9zqGjldHLFMpljlGgnCLY+UDzcm6 +TNVl1SJj0FxnYY2kP0uaBTbDigcA6XQMQ+gZl4/83bTIG4w4SQKbL69jR++ChIefik1 NiCWFcF0vW++NC7WPxhYHpFgmdpRzYHk2ECO2taW0AjcXXBFrSC39Zp37nlRNYhEK24z duvnz5bzH3lmdJtNhfserwgBOM0pEB2iGNOAiVClGu37lV74XrHSGAOiVER6ezLaJz9h ymfjCuP0vW0nzvyk65ujoN1rJpgLBhOqCZw69qo1IaL668STxUftcM3WUdOcWI0kvIjQ 4agA== 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=1wJKTAQwZoynHYJExXVHsyQyNQMZmT7gcHHqSSdTJQE=; b=shRTubTyyT2eVBB33LO8GekGv80rIZ2VV6cb89h6k2Mv1nkvywwNMeYCToG2AesQEH QxnVbdzMDELU7lB3JgJUgSVj1aVKXBHESnGZI8+sbKMULnRSTKvE1zwXtREEp4pAYiYi OgyaryNOnfIdIwAF3ggzmlWsTxIHjG2K48OQR8pPirIlZwFSdEPB85PrklHld6nd87dh mEYzqq/aXheH1rxlY80lVY+ZGghRvIaVI7kNL3cJvCHk5N7f4SDubRISEhKytD/IPJ7l VUIuAU5+UdkzwLrU7O/U8bF6IFHKLtrY5Cv+Pb5Yk7AEkOkesrH/Rq96QnX0OoC55ZY/ /ArQ== 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 jt18si4458979ejb.19.2019.11.08.13.34.45; Fri, 08 Nov 2019 13:34:45 -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 S1732852AbfKHVen (ORCPT + 26 others); Fri, 8 Nov 2019 16:34:43 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:45051 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbfKHVem (ORCPT ); Fri, 8 Nov 2019 16:34:42 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MaInF-1iNMKJ1SOz-00WBZ3; Fri, 08 Nov 2019 22:34:22 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, "David S. Miller" , Eric Dumazet , Alexey Kuznetsov , Hideaki YOSHIFUJI Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Willem de Bruijn , Florian Westphal , Jakub Kicinski , "Matthew Wilcox (Oracle)" , Stanislav Fomichev , John Hurley , Jonathan Lemon , Pedro Tammela , Deepa Dinamani , netdev@vger.kernel.org Subject: [PATCH 03/16] net: sock: use __kernel_old_timespec instead of timespec Date: Fri, 8 Nov 2019 22:32:41 +0100 Message-Id: <20191108213257.3097633-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dHZS9u9EEGjfoUU8DwFFYZFr9GRmH/0v+mphqJL+9zdWkvhrYSd IjhFW4adgcjrYBzyCFla32nOecMkZ7WtqrNYDuLPjbbUaVAqfFEUwnnJdPdZosywpQApddx CwBRz8KhG0DgQk5LRHYpA2Nyccpus4ewZHGyFhMU6ZTzGs+97OmoSj5Z66HJmrU0H+BUrgG OpGJIgPhmUJk6jsa0uQfg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:scDJt0L2i3s=:/0ToOLlNJ3SE+J0uqz1CcQ uqEaJAU2iU3qiFECJgMLAlSwHpUxqfWHl02EDRRsh5ILvCVS30o3bBobHpBzxB3WHHjeDATwY KC20Mf2kGiq2fmh2PVXjh3pwFqhFtDQwdZNkE87fzAFSKAAg8rRKrzsCfYfF+9LpbbFPt2FPY XmjLvY1wXiiqG0N2Yx3ovraqgjppqtFLHu4bkphwguR9+5Mh6Q7Q9WrbrJPYM80FrBfAZEW5m MJRgVhl2CC5VINqjv4YVJcPCKtBUg/l/0lfzv5Y392YNn2aSRJjLKJSmPinDNWkOBV+ICpr3B HjcTRFKg4FBajsYoI5meWzTOjEZ6PLAhH8JlF7hxyrncy7o+S8+8/Q6A236Bj//JMkyKayfBN dY6DO1elP4J+3Jcxby68osNl9L684vZ6/SFe+gk8OmRi/RBIp3e3wf0BiX3UredWF6sIV/BSA ++MBVFOnz5l/hAuilO3ZXvS0Vc3hQ/sBV715NUChQfZMISyyYbSRWEQDtrjJceDVKcUULxSr0 yygz4xrcSoXt4f9ozxETUCEmETv8uqpHzIjjlooiwccrcRCeo7WxXvP0oOJSMrOG14q2Migpj /OiRKhid1N1yzlEvZ8m16fZIQbaNGZ14FL+vgE4HkSWQ3whA3bdAoyr9fg7y3ifzPPfutzfGp IRnUup2M6/MNdzbUmck7/LNvIqj1qJgDCYGuZdiAZK+7303FU7NxtW87QH7/4A9kexC8r6dG/ 7xXIHeMU/5xg6auy0lJUGwT3PsC0Wbh8iwaobHQ6NTTNdPGTohAezNV/KYtoShc66EZgheh9M s/BE56MbGfcOAwQ9/8cpN8J6dd37nFr1VHH0z8CLFhrfBnXLnW+KZGY9p80g8cfDY6p4b5bFR RPbhyrd4d4f3hzy7WbqQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'timespec' type definition and helpers like ktime_to_timespec() or timespec64_to_timespec() should no longer be used in the kernel so we can remove them and avoid introducing y2038 issues in new code. Change the socket code that needs to pass a timespec to user space for backward compatibility to use __kernel_old_timespec instead. This type has the same layout but with a clearer defined name. Slightly reformat tcp_recv_timestamp() for consistency after the removal of timespec64_to_timespec(). Signed-off-by: Arnd Bergmann --- include/linux/skbuff.h | 7 +++++-- net/compat.c | 2 +- net/ipv4/tcp.c | 28 ++++++++++++++++------------ net/socket.c | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) -- 2.20.0 Acked-by: Deepa Dinamani diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 64a395c7f689..6d64ffe92867 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3656,9 +3656,12 @@ static inline void skb_get_new_timestamp(const struct sk_buff *skb, } static inline void skb_get_timestampns(const struct sk_buff *skb, - struct timespec *stamp) + struct __kernel_old_timespec *stamp) { - *stamp = ktime_to_timespec(skb->tstamp); + struct timespec64 ts = ktime_to_timespec64(skb->tstamp); + + stamp->tv_sec = ts.tv_sec; + stamp->tv_nsec = ts.tv_nsec; } static inline void skb_get_new_timestampns(const struct sk_buff *skb, diff --git a/net/compat.c b/net/compat.c index 0f7ded26059e..47d99c784947 100644 --- a/net/compat.c +++ b/net/compat.c @@ -232,7 +232,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat (type == SO_TIMESTAMPNS_OLD || type == SO_TIMESTAMPING_OLD)) { int count = type == SO_TIMESTAMPNS_OLD ? 1 : 3; int i; - struct timespec *ts = (struct timespec *)data; + struct __kernel_old_timespec *ts = data; for (i = 0; i < count; i++) { cts[i].tv_sec = ts[i].tv_sec; cts[i].tv_nsec = ts[i].tv_nsec; diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index d8876f0e9672..013f635db19c 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -1864,29 +1864,33 @@ static void tcp_recv_timestamp(struct msghdr *msg, const struct sock *sk, if (sock_flag(sk, SOCK_RCVTSTAMP)) { if (sock_flag(sk, SOCK_RCVTSTAMPNS)) { if (new_tstamp) { - struct __kernel_timespec kts = {tss->ts[0].tv_sec, tss->ts[0].tv_nsec}; - + struct __kernel_timespec kts = { + .tv_sec = tss->ts[0].tv_sec, + .tv_nsec = tss->ts[0].tv_nsec, + }; put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_NEW, sizeof(kts), &kts); } else { - struct timespec ts_old = timespec64_to_timespec(tss->ts[0]); - + struct __kernel_old_timespec ts_old = { + .tv_sec = tss->ts[0].tv_sec, + .tv_nsec = tss->ts[0].tv_nsec, + }; put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD, sizeof(ts_old), &ts_old); } } else { if (new_tstamp) { - struct __kernel_sock_timeval stv; - - stv.tv_sec = tss->ts[0].tv_sec; - stv.tv_usec = tss->ts[0].tv_nsec / 1000; + struct __kernel_sock_timeval stv = { + .tv_sec = tss->ts[0].tv_sec, + .tv_usec = tss->ts[0].tv_nsec / 1000, + }; put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_NEW, sizeof(stv), &stv); } else { - struct __kernel_old_timeval tv; - - tv.tv_sec = tss->ts[0].tv_sec; - tv.tv_usec = tss->ts[0].tv_nsec / 1000; + struct __kernel_old_timeval tv = { + .tv_sec = tss->ts[0].tv_sec, + .tv_usec = tss->ts[0].tv_nsec / 1000, + }; put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD, sizeof(tv), &tv); } diff --git a/net/socket.c b/net/socket.c index 98f6544b0096..9ab00a080760 100644 --- a/net/socket.c +++ b/net/socket.c @@ -793,7 +793,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_NEW, sizeof(ts), &ts); } else { - struct timespec ts; + struct __kernel_old_timespec ts; skb_get_timestampns(skb, &ts); put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD, From patchwork Fri Nov 8 21:32:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178990 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3312424ilf; Fri, 8 Nov 2019 13:35:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzW6MyzlVQ5ccn3QFUaGnxew6pGXmRHonNKvFT60cHiGtjyAyhUvplmDhOuHFWWjf+axduK X-Received: by 2002:a50:ab10:: with SMTP id s16mr12732569edc.118.1573248904171; Fri, 08 Nov 2019 13:35:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248904; cv=none; d=google.com; s=arc-20160816; b=P42NigbqSGMhP7IzteCReKenn69WR3p+6A8Y+vAMYRKHZVQB60GC4ScHD8DpC2TXFG kZDTAqvIDFoHlq8AW9+m3ZsUCkJ6qAVrhFZSXAn0oa4y2iFBV22YOP6kVQC/sheTdZk+ 6ejlOJfXTqn6/PlX6GEAsyAzfx6rSbtRA25++d1WYZAp6mM/BInoZV3kWkPAvV3dO+94 5PgwRWc/CaqFmjm3piQ/lcG3pkA5ir03OcRiQlVbpx9Yxz3n/lX2m1rJPnagyCFD3Bh7 vDaKtlXrbxiH37AHcVa2ZdVkmTc7iIupzdNZ5FECRvnlF7Vcy0aM0a8YNlUBozxHvwpt yBwg== 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=qXBIDlU0xwzoDWO8fC2ZZrOf/pRpzIi4/cuPh0t/phk=; b=PzxpauPaYOjV7PTudfvueIz0+vcx1FViQZdT5zZ+/T7R2nuSUuBkoWaXQ9XqRHnn+K BQu+xCSqrClpinY9SaXR0kkg2GxKBvetRDDK2Hgdiir38Idv6Q2ykmNx70pbpbOBEMDz 92jlBSLJgEFfKbJcV+1JfUDh5/PWqFMR9bX5qIuV52KIAw6WdL/9aZPc7piY5h7TkAwV +5uSoGTM8ujpYXAJBygoCeTCZETTnRv/qz/bjg0Kodu+iWTaZxbhpqFUE/fQIVRmjh8k SrjXkWIAq5aXEH8QQUJxK7Kc8/rw7eFzo+bMXyRDL2csucfB8OG8ky3JSv2oQhtJdrC+ jDug== 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 a6si5513010edl.108.2019.11.08.13.35.03; Fri, 08 Nov 2019 13:35:04 -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 S1733166AbfKHVfB (ORCPT + 26 others); Fri, 8 Nov 2019 16:35:01 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:59311 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733060AbfKHVez (ORCPT ); Fri, 8 Nov 2019 16:34:55 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MLzSD-1iBFNN1WBV-00Hvwr; Fri, 08 Nov 2019 22:34:36 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Christine Caulfield , David Teigland Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Deepa Dinamani , Richard Fontana , Alexios Zavras , Willem de Bruijn , Greg Kroah-Hartman , Thomas Gleixner , David Windsor , cluster-devel@redhat.com Subject: [PATCH 04/16] dlm: use SO_SNDTIMEO_NEW instead of SO_SNDTIMEO_OLD Date: Fri, 8 Nov 2019 22:32:42 +0100 Message-Id: <20191108213257.3097633-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:uHa/QjAGTByeAkpaDyB/vmnZ68MBZaHn8BbKmiyg4MIyd5kOgr/ oPvkjfCzukaGEqPfPs46BihWpfl4F/gQJ3kQGEB+v25O7LUWaxKwPkPAcNHU8h+MQbnVZAN hd62BomG6NZ5ED6zjrQMrcCfz99gcXhaVP2VS/iuTaIzr8doR+4KM9eIgD8Ug2xmWNmrivZ JpWyIOQrq1vNgXmSWjp0A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Qd/hYklCPQw=:UXlIHNa+YNOfgmM92uODnY g60pWnm0PQin6NlohRtJRMf0RxVHPW8A/DGP+UHxznP/Ger+UlSBqc2mbMr0hiW0ds3eyJVPh OhSJFdBuRA22S+jqbdejdgkWLcJ/202e43Vy6IjyKOyOrRMy6FDKP+bM/frQA6NFGduzOfvFy 4lQxVB6UfEWFmsIV7Y4srgYNNUlK4Qp1BuOFcA206mOMH2dKzCOfEQCtRnz7XZqSvmuBUyRxm 72YtEOhqf+OV5PWrRo0MBLhSWamU8PWM4ZZK85PKCx8AG4RelG3GAFLXH23v/AG3gFDspXUBJ 8WQnlWqDch6EfdHCBcykfnayrAsX0d5zpRL3hrDAIQP2WRb6g+p2wV9Ktu2yW+6RsYM1YcJiR eAIVUFE4MuzRm3uvYjcGnJ3/UEjBiPrQOqkbgoN8mKPbNmFddlukm3WSrUza/gUpQR7i/7dw9 1d9x706JHtWe4fwEM8IzLGSYbkjiWuBJnxGLavzbPfXwvMYzV4x52IJxGbWVdu6DqNNNENbWw SUsk2UlFELckfxqSsK6Agai0whttWZ7nw60jpxXzeqJ3OiwHy+o/f3o/X5etTlxaHcnaD/1KW ztWcZ2okEcUFPNbVrOjKvg85SIqZq3ns/6iamtrEjhHPpCRqk2qGgsw71obLWVv2nssAtg17m vixTARz6rY5KMGRim7d+ffqBUmtFXeeTuNlOlLwPymIjHmeTALMTBHUMJUn9cVBNtBsziCiR9 MPzcK0XbjKvQoazaLhrBabqX5LKRsUQs+NTs7t6b/MHfgx6NC9wMcWiPdQBPuDmKuO55EddN0 zFxE3gb5DxTIPtjdhxPCslQ8VcNyjsEwsGIOsr/uxsNKCRaDgfWpC9xqsqg7kTWMzyADnSB0s UmKbhjv3Lbk+snafAvhA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Eliminate one more use of 'struct timeval' from the kernel so we can eventually remove the definition as well. The kernel supports the new format with a 64-bit time_t version of timeval here, so use that instead of the old timeval. Signed-off-by: Arnd Bergmann --- fs/dlm/lowcomms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.0 Acked-by: Deepa Dinamani diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 3951d39b9b75..cdfaf4f0e11a 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -1035,7 +1035,7 @@ static void sctp_connect_to_sock(struct connection *con) int result; int addr_len; struct socket *sock; - struct timeval tv = { .tv_sec = 5, .tv_usec = 0 }; + struct __kernel_sock_timeval tv = { .tv_sec = 5, .tv_usec = 0 }; if (con->nodeid == 0) { log_print("attempt to connect sock 0 foiled"); @@ -1087,12 +1087,12 @@ static void sctp_connect_to_sock(struct connection *con) * since O_NONBLOCK argument in connect() function does not work here, * then, we should restore the default value of this attribute. */ - kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv, + kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_NEW, (char *)&tv, sizeof(tv)); result = sock->ops->connect(sock, (struct sockaddr *)&daddr, addr_len, 0); memset(&tv, 0, sizeof(tv)); - kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_OLD, (char *)&tv, + kernel_setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO_NEW, (char *)&tv, sizeof(tv)); if (result == -EINPROGRESS) From patchwork Fri Nov 8 21:32:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178989 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3312137ilf; Fri, 8 Nov 2019 13:34:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzprOwMVF2JZezaj6kfiU/mY45CSH/zr2zh2TYF2Lyu9kel+ymdWbtN53hqOyAMpYyIuKLE X-Received: by 2002:a50:e002:: with SMTP id e2mr13095568edl.278.1573248889674; Fri, 08 Nov 2019 13:34:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248889; cv=none; d=google.com; s=arc-20160816; b=BDABv0V8t//8tPNp/VulPfLJLU3BzXvVHmwWgcvi5R9AoQ9CTZKWayCk6fftHIglcS j1A5ABuSjB7ghAmEgqaP1Y/Ze61ujNVcX70z0U85OP/CexPPEr+fToVtV3kjxmKMXltt XSFCew46icQA5UcVv3mhYf/sAYnmQP/866jEiu8s8SBp/uUTEZgG6RrfmYXvwwaqJe99 l5+fKTrB9OyhtJS+L2reMZ2yzFVl08zn5I1Jahp8gKdTIZ0UBFvqxewQn2XcGriQzfyB Us3GCDTtlucd4bI+a5N7DfCvY4y76ErvOJPfsYAPz2TEHtqDEPsW/L8K2oQ94AvOosFj l4pw== 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=EjcZy65GVPvt8e4GH8Tbbzg8JzbcZ5y/42P2IIdjDgk=; b=cIp8TtHyp5YeuK2AOUWPp4ZgaSOv0eTjddnstKfCsMXHfu+kaMnNxe51z9rWJTYnxw BCRO3wv4pV0/ewT4QbbceVPP7OxQOLV+cGWG4q4sK9WuvZtDYNHMe+69otVVUAFJfosZ 8QE0NtclfsWArxvnyO7MUjUon9LelgkvIjZskFaFOhtq7BjOKdjy+X1A/Y8I3Y1/9gDf y/VmI0gKzQ+FNj7VA7IjPlyGDTYu13VObdPS8JLTIssWeIExj7xGEjBcdTK9T+L8y1jj ZGZuBPV+EX5KZUrbUy6RVJ/VBoguba+S7uvR+5nxa+m0nn4d86gtSGzcAEQ4P0Hye0d3 S++w== 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 k18si6247539edj.94.2019.11.08.13.34.49; Fri, 08 Nov 2019 13:34:49 -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 S1732882AbfKHVes (ORCPT + 26 others); Fri, 8 Nov 2019 16:34:48 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:58019 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbfKHVes (ORCPT ); Fri, 8 Nov 2019 16:34:48 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mt7Ll-1he6UG37Rx-00tSYX; Fri, 08 Nov 2019 22:34:45 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Chris Zankel , Max Filippov Cc: linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH 05/16] xtensa: ISS: avoid struct timeval Date: Fri, 8 Nov 2019 22:32:43 +0100 Message-Id: <20191108213257.3097633-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bIxykHQtSe97eNRKLWHHi2P7ZpF4kFV26LIaUxopMvMff0Y6TwS EHpMHJbnqxFRE8Lm5mODfRoD+r3eac3XJ0c2PcWDZciqhG0ddLpIau+NTbR+edYv8nKhw4c x4o34A3GVlLMI4yZ3Ma/1hhqFfNBaWeZIjAeJ37oPMTD+TXbHKYAq6eu7I8i9slW930BcPK uhy384Y8WEvKnM/Tfn7NA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:lglGieAmDc8=:3SS5HATOoJTa0ueQh98NLR Txq527OJbLubazTSr+uZbynA65G8JKR8FiyGu6CNvP0AQ32h7g+xGSpr8KDkgjg6Ph960bVun ri/dCTTEQHWtfX6vfF++BnXPBMt2QpLEs8w5KGiRvroySsmvXQmcbV+wc7xDMIuH+cn1qZHzL CPeNZkgShvd+R/OkvTA8qME4QJiIfM1AqQgOwgn2jd5M7Z6E+47pk7FqrYJAbA9yoGo0ZhDbB Yc4J6nLzSqtbccBN1wvVGMgx4qBsJWdnA6ZZj0b7nNJ6hKvNGIn2qGzKh/eXQ7Khbo0TC1o60 HahpmBei2f6Ju7rWmM/Fy66k473y7VhiRgBI6vmRJSu5BtcS35JReSDDVeBEbmWWqK1c6Byu0 fZHcfeu0a4UuTijAKQvBXiDX6dcGPb7gOfPq9xCgEY9G2QyPBg4Ob6L24lFxO+bJL1dRnK9Xu sLeNB980MVhsnNP2zMLm+bRUSlunldL+oXLle4T1UkEf+arXhxLduDNjJEOz374eWKw7VlTtG T9OyLt2wqJseNFgNDd6xPu7Ub7jEASZ0k18yZxD6XTUo0BVVAy4ZgD22x5F5MkZnkYIzeDITN IxyZ7hiMFPnSQSPWDzxwRSu26Sf0Lk+xqOfuHxg2Z2kCn0Tb3ny49wvlFUuAQLik+3o3bPUHR Chfejv9lBsD9zZCeU+njQadrcMbzdweuiX7UlWBYTp2FAKgFs6EssCzXKuXLNE4DA0zV/X8Z5 0OtdBvZ6j7Sp/25taXA+vU7QaGjufxoDIR7QUh74aFmFBHAh5baLWAZ6cQG6wmWUpA5Qv8Rkf misaXsiy87/On/4iHib79b4GzF3K3vcELrp1Cg9qkAnKZTQMWgA5ri9eaF6RecZ1hG3JSwyQg 5lu1Uf1n9ZMLp209ZYTg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'struct timeval' will get removed from the kernel, change the one user in arch/xtensa to avoid referencing it, by using a fixed-length array instead. Signed-off-by: Arnd Bergmann --- arch/xtensa/platforms/iss/include/platform/simcall.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 Acked-by: Max Filippov diff --git a/arch/xtensa/platforms/iss/include/platform/simcall.h b/arch/xtensa/platforms/iss/include/platform/simcall.h index 2ba45858e50a..4e2a48380dbf 100644 --- a/arch/xtensa/platforms/iss/include/platform/simcall.h +++ b/arch/xtensa/platforms/iss/include/platform/simcall.h @@ -113,9 +113,9 @@ static inline int simc_write(int fd, const void *buf, size_t count) static inline int simc_poll(int fd) { - struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; + long timeval[2] = { 0, 0 }; - return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&tv); + return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&timeval); } static inline int simc_lseek(int fd, uint32_t off, int whence) From patchwork Fri Nov 8 21:32:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178991 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3313409ilf; Fri, 8 Nov 2019 13:35:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwdqavWPuc5sW1JE15JmS9j6++O5KwrGB3QQ3jWFcdbKEFR0kFUmV+7Q8P3qEsMxC8UBH0Q X-Received: by 2002:a17:906:af62:: with SMTP id os2mr11293954ejb.105.1573248953249; Fri, 08 Nov 2019 13:35:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248953; cv=none; d=google.com; s=arc-20160816; b=F+VVO8CUWGVbkzpN+J92zkz5zTSS+sWg2q37GF+S6BKFS7kB1JSVCupBUpY4cSSFRv CxIclX9tGHjHUw+aPgbntIP/FJqeGKoeNxdHJLgnLTZRtH9aZkcDyNQyPaiu/eHbo+tV Q/ZfecG0rw52nMDiMUkNZx63soQ3wFkQeZfaZbpMNROvbrAggL3uvjEUYTiwzeke535V ApscF6DPOuCGlVr0BIjyRj5DIPApU5cfWt/eI6IaWRMgairKtMvdpuQbjqNkxPtitnuN nC7M1T9LZLbRJEA0tzGyT59C4Ty87L3KLxx1BY/3MZfkuG3Q/yvQFnFC90A0Tq1+ZzOi dcWQ== 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=ur6ghsqsHfbHTMC2isb5Ktvb7FbvTyv0GhCsohnn8pA=; b=zwyhrMQuT6R/6RfMTXuIYN854dUtRgZKpGwB1xa8noUDftwIYTgUejpjxrnALu++il d8Yo5tUeK21tRdBhcFwoda7UWL6Im+YZFRi4R7ezvtJ/5VWJg1Q5p2CvG47lv/6nPyUn a7vOVZTE11oTjmNW3HTMtCvQfcufu8WWvkylF/xKv8/kWiM7/RD3G7+u4cA6DDiuFz25 jJVya4LcYOmclchjrpyvNkzA8AvwSQ3ZU8rjf63Bseo1ufugQm1nobzAisEN5LHISV/B f4uf0H/2VcWrVpyrdoEP88dSq5opWzBj0KJubq8FQue5W0ZRvBSBkMriSfVpyBQOanSo WYSQ== 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 v2si5501721ede.61.2019.11.08.13.35.53; Fri, 08 Nov 2019 13:35:53 -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 S2387678AbfKHVfs (ORCPT + 26 others); Fri, 8 Nov 2019 16:35:48 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:42431 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731657AbfKHVfs (ORCPT ); Fri, 8 Nov 2019 16:35:48 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1M6UqP-1iZUMu0OVt-006yfN; Fri, 08 Nov 2019 22:35:17 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Jeff Dike , Richard Weinberger , Anton Ivanov Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Alex Dewar , Daniel Walter , Johannes Berg , Erel Geron , linux-um@lists.infradead.org Subject: [PATCH 06/16] um: ubd: use 64-bit time_t where possible Date: Fri, 8 Nov 2019 22:32:44 +0100 Message-Id: <20191108213257.3097633-7-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Kz5NxHHOvfJYq5W0loqpTgWDD5GLAn6p6huhGseqlIGjUxpqs56 erxGZ8PolN8DzkmutO7TPQe5q3wxkEU3RCNiYlW5wJtalQYwR6PmaPVhf1HaCzY5o0fj+nD YoXhDXSOKPWecRlA79QqQVTFWO+XadBooMOiOn3QBBxIVKz90NsdAavZscpPxBdSeVVG/NL PmCoJjOEvbJg5j0AalAvQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:gH4cxcsvPPE=:hhkpbE/jGdEEZKP4uMAozT ejzlw1RW5qktKjWGSMModOSILhU75yjNTk80hR/hGjz8RbthKD8/CDonT45r+z6whSMIhMi25 VXwWGbHyZpJwpSKs1TSIaeGWZ3L2jFNdlI3cg51W0eCXBHbt6w8nqvVFunZPHPrDE55wWQGLS GLL/Jp/UAJrt/PI05CL/daHMETqQ//nkvq5OBqYNldxrgPW4ANogae9aU1MhHmawMZAsBiydc Wb5mPvc1WIPL6ERpQzHCA6FLyGV1wif+59yICf9sLQxUFo/J04MSQf0bYBPRAARf4h6ggpcyt H0PBILdXHVPB4TFzrHjEu8ExdPG/kBHdOjWrTuwWlbM2/CljE0dWZvoraRqwW43j0nY6zcl1g /labk9EUo1NRB3lEF62GsdZBEhOSnj7+NksyMBYMay3DsVbKNhhMW9dvv9VPjvWAguIjY6crl rD3raJk1+aALmjq94cII3T3fBh5uXqj1GcwEQfPmy7hXQbmgcI2dqo8+Z1yWlCbEb3a/ntuaI +oyF0A52DEmCjquGivmTJDbekX0hLNajdLoCFHrvJ2lv8CQUdiYXNBZqV+NFFSh52uNXliuHW Oa3mh/DErS/6lxfND6HRzNdDGAGH+5ohSwlcVG4zt+9ebvJOtm8/lmPFISdzUgPm9QrJJzO+B uxebqZrmBaKZp4mAgWCPOerw6NhBf6iCE3ZSrt0O0zkgwObq0ywe3eZuZwjsXBbcTW9X/CrGh 5fF8/5SV+apzzPN3K2XgDkMLQ78KhJEEishwJBbpGV7mDetMJFF94lwJmwowih6zOSv+Hab6h bBvJe/uuZjIcyclTDAawK98ZHCmgTkTe1gnvGrcOP4XopQFQ6/hxQLDUFrnTkPm+esK0lR9At Dhn1NqhVQnn099gvMTDA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ubd code suffers from a possible y2038 overflow on 32-bit architectures, both for the cow header and the os_file_modtime() function. Replace time_t with time64_t to extend the ubd_kern side as much as possible. Whether this makes a difference for the user side depends on the host libc implementation that may use either 32-bit or 64-bit time_t. For the cow file format, the header contains an unsigned 32-bit timestamp, which is good until y2106, passing this through a 'long long' gives us a consistent interpretation between 32-bit and 64-bit um kernels. Signed-off-by: Arnd Bergmann --- arch/um/drivers/cow.h | 2 +- arch/um/drivers/cow_user.c | 7 ++++--- arch/um/drivers/ubd_kern.c | 10 +++++----- arch/um/include/shared/os.h | 2 +- arch/um/os-Linux/file.c | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) -- 2.20.0 diff --git a/arch/um/drivers/cow.h b/arch/um/drivers/cow.h index 760c507dd5b6..103adac691ed 100644 --- a/arch/um/drivers/cow.h +++ b/arch/um/drivers/cow.h @@ -11,7 +11,7 @@ extern int init_cow_file(int fd, char *cow_file, char *backing_file, extern int file_reader(__u64 offset, char *buf, int len, void *arg); extern int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, __u32 *version_out, - char **backing_file_out, time_t *mtime_out, + char **backing_file_out, long long *mtime_out, unsigned long long *size_out, int *sectorsize_out, __u32 *align_out, int *bitmap_offset_out); diff --git a/arch/um/drivers/cow_user.c b/arch/um/drivers/cow_user.c index 74b0c2686c95..29b46581ddd1 100644 --- a/arch/um/drivers/cow_user.c +++ b/arch/um/drivers/cow_user.c @@ -17,6 +17,7 @@ #define PATH_LEN_V1 256 +/* unsigned time_t works until year 2106 */ typedef __u32 time32_t; struct cow_header_v1 { @@ -197,7 +198,7 @@ int write_cow_header(char *cow_file, int fd, char *backing_file, int sectorsize, int alignment, unsigned long long *size) { struct cow_header_v3 *header; - unsigned long modtime; + long long modtime; int err; err = cow_seek_file(fd, 0); @@ -276,7 +277,7 @@ int file_reader(__u64 offset, char *buf, int len, void *arg) int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, __u32 *version_out, char **backing_file_out, - time_t *mtime_out, unsigned long long *size_out, + long long *mtime_out, unsigned long long *size_out, int *sectorsize_out, __u32 *align_out, int *bitmap_offset_out) { @@ -363,7 +364,7 @@ int read_cow_header(int (*reader)(__u64, char *, int, void *), void *arg, /* * this was used until Dec2005 - 64bits are needed to represent - * 2038+. I.e. we can safely do this truncating cast. + * 2106+. I.e. we can safely do this truncating cast. * * Additionally, we must use be32toh() instead of be64toh(), since * the program used to use the former (tested - I got mtime diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 6627d7c30f37..dcabb463e011 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -561,7 +561,7 @@ static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out) __u32 version; __u32 align; char *backing_file; - time_t mtime; + time64_t mtime; unsigned long long size; int sector_size; int bitmap_offset; @@ -600,9 +600,9 @@ static int read_cow_bitmap(int fd, void *buf, int offset, int len) return 0; } -static int backing_file_mismatch(char *file, __u64 size, time_t mtime) +static int backing_file_mismatch(char *file, __u64 size, time64_t mtime) { - unsigned long modtime; + time64_t modtime; unsigned long long actual; int err; @@ -628,7 +628,7 @@ static int backing_file_mismatch(char *file, __u64 size, time_t mtime) return -EINVAL; } if (modtime != mtime) { - printk(KERN_ERR "mtime mismatch (%ld vs %ld) of COW header vs " + printk(KERN_ERR "mtime mismatch (%lld vs %lld) of COW header vs " "backing file\n", mtime, modtime); return -EINVAL; } @@ -671,7 +671,7 @@ static int open_ubd_file(char *file, struct openflags *openflags, int shared, unsigned long *bitmap_len_out, int *data_offset_out, int *create_cow_out) { - time_t mtime; + time64_t mtime; unsigned long long size; __u32 version, align; char *backing_file; diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h index 506bcd1bca68..0f30204b6afa 100644 --- a/arch/um/include/shared/os.h +++ b/arch/um/include/shared/os.h @@ -150,7 +150,7 @@ extern int os_sync_file(int fd); extern int os_file_size(const char *file, unsigned long long *size_out); extern int os_pread_file(int fd, void *buf, int len, unsigned long long offset); extern int os_pwrite_file(int fd, const void *buf, int count, unsigned long long offset); -extern int os_file_modtime(const char *file, unsigned long *modtime); +extern int os_file_modtime(const char *file, long long *modtime); extern int os_pipe(int *fd, int stream, int close_on_exec); extern int os_set_fd_async(int fd); extern int os_clear_fd_async(int fd); diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c index 5133e3afb96f..fbda10535dab 100644 --- a/arch/um/os-Linux/file.c +++ b/arch/um/os-Linux/file.c @@ -341,7 +341,7 @@ int os_file_size(const char *file, unsigned long long *size_out) return 0; } -int os_file_modtime(const char *file, unsigned long *modtime) +int os_file_modtime(const char *file, long long *modtime) { struct uml_stat buf; int err; From patchwork Fri Nov 8 21:32:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178992 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3313415ilf; Fri, 8 Nov 2019 13:35:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxITLuwS3hUfgUgCJykZKaGFW/x4Bt74P/sG7Ozvwl1ZCpQiTaVKV7sCMJ/aXTVs+MC6Iqk X-Received: by 2002:a17:906:bc9:: with SMTP id y9mr9015080ejg.64.1573248953698; Fri, 08 Nov 2019 13:35:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248953; cv=none; d=google.com; s=arc-20160816; b=ORSyKijPEmR1xHwwjvzGCIkLFPY/bdWbXNIfLHpMPwDv41lui31ERpVszfffFb2Oe0 ZlyO7TmWxY5pyda5Igf0bi49QiG5OXtZb1Rxid4d5OGamPRsCnOHLiyuy1FNoU4yc6AM HeJ2/7W4agj32RmlsWURSVLUdR3Oi+lmmgGmYMHiAGnmUAWGsX++CIhupOx4gzsW8HIJ MpAP9FdLAhbL2oj2vpZG5W6qSzDr7INeYWfXvZnbhO04MTT3VZSz9axhdtzXTH86uijf gVEqmsvz92uXJLBAcNJA1EjJaRugvn1DtUy73NTCn/0MvIqsWrKp1p29cLa4YHk62snz c7dA== 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=/EIJXv4Rd5fLnsILTNp7L9ciVJLbLbdXCnfxYhN/HEU=; b=GTHGhuatJhRC4vEhOsVAdiiMkfXYYzqikrzv3uYDiPK6WdluV6oiJf4bcPvJGSaGDO 1fRxrf36gidU2H/BSH6o9FUhFB+F4gIpwk4bT/MnMpHTT16cTfYhWF3ADanGD+mWGSni s1Ua+flgr9LySRusmcuznoVAztWAj3g9CTcoFwcj/7diYV78kbd8WHjeCG7C8AOs9cpS j2WsMnYUCuseETjnOyuseHofMZWbwEF1HR8GE76O4gbqi04pUkZpgBvyN5G7u2QmkbCh 4zFLhmotec5Id9yWoDeGOtcyI/MtTqmW4mqgtQpbd0LbG/YaOmPKCBnp01yRRdOb5UIN YL9w== 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 v2si5501721ede.61.2019.11.08.13.35.53; Fri, 08 Nov 2019 13:35:53 -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 S2387802AbfKHVfv (ORCPT + 26 others); Fri, 8 Nov 2019 16:35:51 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:37887 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387700AbfKHVfv (ORCPT ); Fri, 8 Nov 2019 16:35:51 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MyK1E-1hheq037vA-00yfkO; Fri, 08 Nov 2019 22:35:40 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Al Viro , Thomas Gleixner , Richard Fontana Subject: [PATCH 07/16] acct: stop using get_seconds() Date: Fri, 8 Nov 2019 22:32:45 +0100 Message-Id: <20191108213257.3097633-8-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:MvCmw8KZeUaCp8UqvAYmNhTL2rs0z/UL28/zpU8LBknjj8+U4pP pcYX5LoofEAaw6KYwpc6x17n34w/sKg6L9j6t/L4zZY7B6fKAZcIUpK2mXEKU8Mtbj4Q2de qEnNGj9XgUf9aYvlWbmVmwSRw8O38+8uX8yuBMGU4hHJBR5GtxWSYqgHkPFpXB8gbkFLvcZ QhE0VAW7PqzOU1XQoLp5Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:4RFwLd9Ulic=:rITuPaqqQQO0WKu19dX8Tj Jm7c02EzCGuP2qODrhxkcuhXNv2+4aBeDdZAo7JiVra27cEP9Hmuv7YtlJbIiLsjeUbEFRznA g8TLpWCooqVYSlFnCJerjeLaKicNV1Gu2OixEJ/GARxSKas1KXt+0OSrkQMtH0zC3FH1W5dfz KP8tk56zSUp9hKHChaDeYdZnIeNqdfCMTL6fNOFqcQc0HLofvEo5imk6WDHgjmnsda8LvhDpH APU1qxqtGaIhQ13KNvWNfGPnf//JNE0ypNnraxc16pPQc0rFp0p0sp40M6dnc7ATGxI2tgOLM IW2m+4uqKbX8OzjW1s2Oy2PRkedwtZBOUULXgPZE8QGZt1gRHZSBKvkDkUtWqwnVf8teTdjA7 vat1HR6p1GTIHWniLEMmhBtVCmsOHEXDK6hRXY3IFPInVNfs9CQvxO3uPwvMfinYcwXJevRza 1fCHW3LXFAWGfXiUqHBMG+blCR8T8bGKYlmdBYH1DfdpYctFWXgIwZA5iw6uXjeyvAikAkOxZ z+QeI/N816XcY2gNgQuoM+n0ZANbrSuyBgLqJ8JFgSrZzaSatmEYFd6VjMwMPf8t/zhweL89d Keq4AL/5KVX6aiNLg+dBuDgBQbr55y6tBBnvI4P5urfLwhqyjxUEP9hbx4pEWrjZY4TuqsKnk 7cn1T8pzkv2e10YFZNYA+twYD6mkk46atnArJi3BwNorZuv/0+FI3f6PIU3A0iA9YG+/yixDa mYTbtvuAZir5DhVTF1YxfoSJh4wQgPn/JKEVo1Kr93/7BFIZrClvLomRphRhpRKm7eqLu/XuX 6J++42E3FR02EP8nlHBG8YZ/kh3gNCQNiJsZWa8OMViGYhshwLGQuFrrPD4YmUuX9oE3R/9IK EIfRk5sFTd+jO5CSffig== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In 'struct acct', 'struct acct_v3', and 'struct taskstats' we have a 32-bit 'ac_btime' field containing an absolute time value, which will overflow in year 2106. There are two possible ways to deal with it: a) let it overflow and have user space code deal with reconstructing the data based on the current time, or b) truncate the times based on the range of the u32 type. Neither of them solves the actual problem. Pick the second one to best document what the issue is, and have someone fix it in a future version. Signed-off-by: Arnd Bergmann --- include/uapi/linux/acct.h | 2 ++ include/uapi/linux/taskstats.h | 1 + kernel/acct.c | 4 +++- kernel/tsacct.c | 8 +++++--- 4 files changed, 11 insertions(+), 4 deletions(-) -- 2.20.0 diff --git a/include/uapi/linux/acct.h b/include/uapi/linux/acct.h index 0e72172cd23a..985b89068591 100644 --- a/include/uapi/linux/acct.h +++ b/include/uapi/linux/acct.h @@ -49,6 +49,7 @@ struct acct __u16 ac_uid16; /* LSB of Real User ID */ __u16 ac_gid16; /* LSB of Real Group ID */ __u16 ac_tty; /* Control Terminal */ + /* __u32 range means times from 1970 to 2106 */ __u32 ac_btime; /* Process Creation Time */ comp_t ac_utime; /* User Time */ comp_t ac_stime; /* System Time */ @@ -81,6 +82,7 @@ struct acct_v3 __u32 ac_gid; /* Real Group ID */ __u32 ac_pid; /* Process ID */ __u32 ac_ppid; /* Parent Process ID */ + /* __u32 range means times from 1970 to 2106 */ __u32 ac_btime; /* Process Creation Time */ #ifdef __KERNEL__ __u32 ac_etime; /* Elapsed Time */ diff --git a/include/uapi/linux/taskstats.h b/include/uapi/linux/taskstats.h index 5e8ca16a9079..7d3ea366e93b 100644 --- a/include/uapi/linux/taskstats.h +++ b/include/uapi/linux/taskstats.h @@ -112,6 +112,7 @@ struct taskstats { __u32 ac_gid; /* Group ID */ __u32 ac_pid; /* Process ID */ __u32 ac_ppid; /* Parent process ID */ + /* __u32 range means times from 1970 to 2106 */ __u32 ac_btime; /* Begin time [sec since 1970] */ __u64 ac_etime __attribute__((aligned(8))); /* Elapsed time [usec] */ diff --git a/kernel/acct.c b/kernel/acct.c index 81f9831a7859..11ff4a596d6b 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -416,6 +416,7 @@ static void fill_ac(acct_t *ac) { struct pacct_struct *pacct = ¤t->signal->pacct; u64 elapsed, run_time; + time64_t btime; struct tty_struct *tty; /* @@ -448,7 +449,8 @@ static void fill_ac(acct_t *ac) } #endif do_div(elapsed, AHZ); - ac->ac_btime = get_seconds() - elapsed; + btime = ktime_get_real_seconds() - elapsed; + ac->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX); #if ACCT_VERSION==2 ac->ac_ahz = AHZ; #endif diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 7be3e7530841..ab12616ee6fb 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c @@ -24,6 +24,7 @@ void bacct_add_tsk(struct user_namespace *user_ns, const struct cred *tcred; u64 utime, stime, utimescaled, stimescaled; u64 delta; + time64_t btime; BUILD_BUG_ON(TS_COMM_LEN < TASK_COMM_LEN); @@ -32,9 +33,10 @@ void bacct_add_tsk(struct user_namespace *user_ns, /* Convert to micro seconds */ do_div(delta, NSEC_PER_USEC); stats->ac_etime = delta; - /* Convert to seconds for btime */ - do_div(delta, USEC_PER_SEC); - stats->ac_btime = get_seconds() - delta; + /* Convert to seconds for btime (note y2106 limit) */ + btime = ktime_get_real_seconds() - div_u64(delta, USEC_PER_SEC); + stats->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX); + if (thread_group_leader(tsk)) { stats->ac_exitcode = tsk->exit_code; if (tsk->flags & PF_FORKNOEXEC) From patchwork Fri Nov 8 21:32:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178994 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3313636ilf; Fri, 8 Nov 2019 13:36:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzzC9iTMMTvg5wDrO/Okk3LkFjGhA3idqfh8g4lROummWej1etEqrcVr8FdHmrNzqr2+upc X-Received: by 2002:a05:6402:213:: with SMTP id t19mr13010289edv.7.1573248963225; Fri, 08 Nov 2019 13:36:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248963; cv=none; d=google.com; s=arc-20160816; b=U3eOmANzVPr8kaIe1cFOAl/hagDFHZX6mEnd81NMWJpxxMMW5KRikxcXDZqix0QovE mgKNGuUf5az48k2uixAsMh+uoYmeT4EjOqkKCbNpHUkUldo55Tu6i/TgQxsQVmC/GXOC gXcUnSe9QdBic+EtktETDQ56ggRtiTI6oYILCRy1eNlUQWMs0hr8ccOup6AZt5YfJ28/ Iigs3aM8mKqGSWidM9XNadEDNNQMenyxJppa/gbnQgBVL+TbEnTsUvVMnAXGdKOXfli+ ZEotpRAsWh+ZVfr7UiPdk/lVSOfpmG+Uf0xxJB8sav+wQqIGbUOxY3Vf5hGoxuUKoJSp mjag== 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=yw97vSkCj+HfHKYZWLHnKqYhQC9/rG95VgHdYU9rCPs=; b=ApqgBPIFVKzI/69ARdpJURv6npebzi5xT4ZO7bzz8WJA9IQLrWNaFQydWXEoqErQRY 0Pz5w8g4tI3Dku/xw8kzscBm2/5YF9+SW8yTnN2YORyYssP2lkSiTkkl7MzyoTOvfVRZ lj3Z6oXkkGNh+GdgjPzLdDSHHbXCzyA0MbDyD2p+2NN1IAD4YXxW5hsc3yi2B1MpFYa7 W5CQQv0lF4GgBkgxl2Nw07rlUD11N8Xemk6vUwWVG5887Fnt/GnO/9hVAOnQWKQMvCuA ABrtszp46vo3rR+vouPNIBuatHrDMTqEolZWsgwafB1Hu//9aaaout6X/acjBEnaPKUL 6v1Q== 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 dt11si4802181ejb.126.2019.11.08.13.36.03; Fri, 08 Nov 2019 13:36:03 -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 S2387962AbfKHVgA (ORCPT + 26 others); Fri, 8 Nov 2019 16:36:00 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:48263 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387700AbfKHVf5 (ORCPT ); Fri, 8 Nov 2019 16:35:57 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MRC7g-1iEnnH00M0-00N98i; Fri, 08 Nov 2019 22:35:51 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Thomas Gleixner , Kate Stewart Subject: [PATCH 08/16] tsacct: add 64-bit btime field Date: Fri, 8 Nov 2019 22:32:46 +0100 Message-Id: <20191108213257.3097633-9-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:3+J3uRariZxxM90pMCKHnHOIPfnwPSLhxD7qOTYUVh3SZ+JnOFK VgE/W8pe5KqQiWz/onPIr5xkbYNXoU05ZXKz9Ur1T4KKbn55mDc736fX98L1y4kNR1sVl+E eJ+aGZ5iEbt0dGFkbfWunoEWg1qg93cxn7nXS0JHShvtXBZXfISyaiCUKqXP/DJmACan0V/ DQ8ayfOjgUjuzE1dRVSKg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:taJmWacjwUo=:jr/dEAhQn68wzbMKnfMDqL 6Trhqpo0PcSePSySdrLaqoFD3YsWRrcfJGFidUMcseJjIG02n2xadFKWP4tqT5sJM0ORXGjiy HknMtrs50T4QateXUoDx6LDSZGEvxMhEui+Y7ekbhuFh+QgnMOTCJRWlC2PYczvC+nF+nNeLO L+Zg7VrudI22dMCln1JQEMge9JtAoHqhRMGYbWfjSMm3ACsdZ4doRuvJbT8vsRPdVfc6/7xel wGjByAa+2Wq5UKwOtUor7w+1FDBvKmF+rf6Toc0LE+azWpsTt+GTavipZ2txqUFfr8I/3uY8p enDWDzEB0bdiplvgNb6YELjHC7e1z5RpNFSf4ewQyz91wzSXxKAPp0KDwBiPbhM6qnMsHi8su bpd3g/IdgHYUl3p4tLVH9m3ZtfWNe3MKeOpLtu0NNrl4Tur6WTUbUQvwmj9MXi4KS3uKlruUx UlF429FjvvlKF/iT8yINQWWRg3HRtlfi7RoSIyQCdH2d1W/cpSl4zI0uApgJUfQIj2l8eSdHa FXJNfMEvrUtpbbrllLeIfg+5bztFXiFTZiUUzdNvXQTemvBJlztoiHFSy/CQ1iqOU4dTL7yG+ eYkgZCO6isfij0b/H+F9cVuMhlsjW+1VU12AwwUySvGLW80M7VFbs/x1o0opar/YLu8nabZEg ooKs4URxFevO8UZkM3Jp3lLIJM4qM5XlsT5GWbX4Lf5P8JVoeX4BVQCjGKSfGxoM6epaLDQpe sVrjaI5uOgJ1lw8xAbc5OL3ugCWf8h3e8McYj1/TSbkAepgwAIjSEQrNXqQL1fQlh3RVsi7LI H3n1Cr+8v8LyNBUqjKLQDAEOQBu2S6v4+MKzrLg16vKj8P9se47KDiLNqFChBTy8W2XDRR0rd U6GSJyTjWManXM6BSsCw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As there is only a 32-bit ac_btime field in taskstat and we should handle dates after the overflow, add a new field with the same information but 64-bit width that can hold a full time64_t. Signed-off-by: Arnd Bergmann --- include/uapi/linux/taskstats.h | 5 ++++- kernel/tsacct.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) -- 2.20.0 diff --git a/include/uapi/linux/taskstats.h b/include/uapi/linux/taskstats.h index 7d3ea366e93b..ccbd08709321 100644 --- a/include/uapi/linux/taskstats.h +++ b/include/uapi/linux/taskstats.h @@ -34,7 +34,7 @@ */ -#define TASKSTATS_VERSION 9 +#define TASKSTATS_VERSION 10 #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN * in linux/sched.h */ @@ -169,6 +169,9 @@ struct taskstats { /* Delay waiting for thrashing page */ __u64 thrashing_count; __u64 thrashing_delay_total; + + /* v10: 64-bit btime to avoid overflow */ + __u64 ac_btime64; /* 64-bit begin time */ }; diff --git a/kernel/tsacct.c b/kernel/tsacct.c index ab12616ee6fb..257ffb993ea2 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c @@ -36,6 +36,7 @@ void bacct_add_tsk(struct user_namespace *user_ns, /* Convert to seconds for btime (note y2106 limit) */ btime = ktime_get_real_seconds() - div_u64(delta, USEC_PER_SEC); stats->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX); + stats->ac_btime64 = btime; if (thread_group_leader(tsk)) { stats->ac_exitcode = tsk->exit_code; From patchwork Fri Nov 8 21:32:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178995 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3314318ilf; Fri, 8 Nov 2019 13:36:37 -0800 (PST) X-Google-Smtp-Source: APXvYqy2OjUK/9JoXAtyT3tr7cxP0XtOm5dlWHYz+1pBZJOMM0NwWsUduk6pfJxPz8mKHj26IekC X-Received: by 2002:a50:cd53:: with SMTP id d19mr12783427edj.197.1573248997369; Fri, 08 Nov 2019 13:36:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573248997; cv=none; d=google.com; s=arc-20160816; b=ZaJQA5lwvL061h4k/YMjqMMqx9EigEcu+sBICHP5Filt7ChgyGHGOz/Ky0VXH83p7t x+uYyWAdzJUj2LfA3gFxPFj+E+6vXfyGP5YqlM+QR0i/ptRSaR4hPZZoeM4xoZa1uzXN rR6qkNru+9MVKBgTrHeyBn+X0RvyPwnOQ5v6RhnXcpjc+2R0iQuhfUDROMFZEXyecsJo g3TIYoJZOa75ZwNFnGpYVUNWrJePxv3qnd2I5XCsEBmp4v30qEEYaXjBVtnzjA3i8oYa Q3xRFmEDwWjjMOrXbgJmzAishOAHcFmDeOlqRpXUzcLyk7F20RA1BKGuPrT+04JMQM7w RAVg== 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=bbQeQP3+so1cFFwWtrJ6oStBYdEDKbrdTZBqJQZoXKI=; b=W8lK1bsyEFNMVpCnMxsmxr2zDkkDYm1lxdVd/FvtuLf1dXDKIFhpcHxV7GyrcXfr1G TUHwbl+EthtkpY8Tv286i0nVFYMrdqtXStHUHoylKz4b79Rvg3zk+MTtZGZmUrfadfkA UDc6rCdedSmYMftqkRlLs0U3vGq0/knLxuibggJSvgXqnl3V09g9heWpVVnnTHr+S+Yr X6l0FwqZ38aoB7jhRVSqtZjI15UiwWXygG08CI8EdynR/hu52uCnFhHTp6aMGjPu+44X ZgANQaquWKFgTLnRBbzcmJiv4diQ2LlbhtKrYHZAF6qR+npHH9Fn0YAVlZfJk29Ulltu 1Yvg== 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 x19si4491123ejv.94.2019.11.08.13.36.36; Fri, 08 Nov 2019 13:36:37 -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 S1733257AbfKHVgc (ORCPT + 26 others); Fri, 8 Nov 2019 16:36:32 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:40285 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731657AbfKHVgc (ORCPT ); Fri, 8 Nov 2019 16:36:32 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MHXSD-1ig8Ef1y1B-00DYFh; Fri, 08 Nov 2019 22:36:12 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Ander Juaristi , wenxu , Thomas Gleixner , Phil Sutter , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH 09/16] netfilter: nft_meta: use 64-bit time arithmetic Date: Fri, 8 Nov 2019 22:32:47 +0100 Message-Id: <20191108213257.3097633-10-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:8e4BtkTZhkDHnhj4em5WE6DJ2Vkq2Wh8mzdxKAtzODBb4B8f/ed 1DGYs7ESWLEtqmT/CcVkHt+/jTl1TdrlCbYVhmDWsfDO6ZSQ/WOUgNlu6NcnJYc1TIxaznY ICGDL51il9EAV1ONkEj2C3NvH/5CeXp/Ah0RZdx3J8g4pFdkn0H2eqIASfMU4ZCCfw4FYqq mIeUVaqKsjByJJ274lYZw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:BXMIyk7bYig=:/XFifkUlnyQ21O7sbEHUKu Nd04r+p1qEyeBSJA6OQQIt0C0EEJhrJu5ULg7ArJrDLL6Sc+zGcRT2eBCMuyKOVu2pbT3y/KO Qjz3kLq+YSfMw05N8pByhJ5Sgk6lAhl+XHfMQJ47ws5al9fl6GCjo6LjmhfQj6KLsM+hiIxBk 7MdHAuoWEcT39E81h/0I9+oL89nPaFCLqPnZwTmSF/FWjpqM8nOSRaiwqQ3i4wCeLjz5qpSK/ Xlz8ivOmvP6eDQybCUGKiusaZob3Qu5J1HT+iCkdwbkCW7VezbiowHMrx6+YAaoWZ7oGqMCjI WNzx2cn+FrVgdxhuePz8qk4yxVoexAwMSYFO8tqcSk2NNCPR+l98/Typ+IDnPBTB6/aYvvFTc FLnYlQSfhTbqhm7CRlSAD/Jn2cZr4mJFwenXeyx9jqGvK0epNm3bI4T1s8AXxUdDpZOtAmxsN ytctvQbk+kMS6sen/4zxK+MYwgkH4dA1S1tCPAcGk6OnxFcf5hVGCU5G3Oa8gD1SlOelgFWuh 3k44ZAjp5/YcrPu3k0aytdVAsWbsZGtej2QVB3mX67/nuj7nS+U6fsqXFr2WEiIFCw2B7cThx ZEYPdBFwbvKL8mL9h+2pzE2OpEcIW6u5gIxgnJCyNPHK5LD4DWbgvmyq65jrxITTE7ZKx3e43 G4moguidGfoX3WGwk4MIoD2sLEVWdV0CW5uafFnB/gUYt9Glob0OWX1xCp8kE4ecBHLbTw1be QRiyX7UFJf7QgjYwIpVuhdzqNhLTUyjg8kL8LUDxKbM9tKn/s6AOmtXzmJCtRnnPNXq/G3bxT 4DDfDS0cJZl/SuY3dszyqTxUmYYoADpxh/WaDiqwS6tX5SK+eGIVmXzM1p/bDz9QrQ3o4OdXn +8OEInWfu8d0Wk8i3ssw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 32-bit architectures, get_seconds() returns an unsigned 32-bit time value, which also matches the type used in the nft_meta code. This will not overflow in year 2038 as a time_t would, but it still suffers from the overflow problem later on in year 2106. Change this instance to use the time64_t type consistently and avoid the deprecated get_seconds(). The nft_meta_weekday() calculation potentially gets a little slower on 32-bit architectures, but now it has the same behavior as on 64-bit architectures and does not overflow. Fixes: 63d10e12b00d ("netfilter: nft_meta: support for time matching") Signed-off-by: Arnd Bergmann --- net/netfilter/nft_meta.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.20.0 Acked-by: Phil Sutter diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c index 317e3a9e8c5b..dda1e55d5801 100644 --- a/net/netfilter/nft_meta.c +++ b/net/netfilter/nft_meta.c @@ -33,19 +33,19 @@ static DEFINE_PER_CPU(struct rnd_state, nft_prandom_state); -static u8 nft_meta_weekday(unsigned long secs) +static u8 nft_meta_weekday(time64_t secs) { unsigned int dse; u8 wday; secs -= NFT_META_SECS_PER_MINUTE * sys_tz.tz_minuteswest; - dse = secs / NFT_META_SECS_PER_DAY; + dse = div_u64(secs, NFT_META_SECS_PER_DAY); wday = (4 + dse) % NFT_META_DAYS_PER_WEEK; return wday; } -static u32 nft_meta_hour(unsigned long secs) +static u32 nft_meta_hour(time64_t secs) { struct tm tm; @@ -250,10 +250,10 @@ void nft_meta_get_eval(const struct nft_expr *expr, nft_reg_store64(dest, ktime_get_real_ns()); break; case NFT_META_TIME_DAY: - nft_reg_store8(dest, nft_meta_weekday(get_seconds())); + nft_reg_store8(dest, nft_meta_weekday(ktime_get_real_seconds())); break; case NFT_META_TIME_HOUR: - *dest = nft_meta_hour(get_seconds()); + *dest = nft_meta_hour(ktime_get_real_seconds()); break; default: WARN_ON(1); From patchwork Fri Nov 8 21:32:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178998 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3315517ilf; Fri, 8 Nov 2019 13:37:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyjR36DtwYRdzW3d+QcIPJxDx8hfcpkvvjgPJBVmBHriRcX7ZHsixhmwNZuFOZrHjdR0r5V X-Received: by 2002:a50:9908:: with SMTP id k8mr12678237edb.75.1573249059998; Fri, 08 Nov 2019 13:37:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249059; cv=none; d=google.com; s=arc-20160816; b=S0dM6beaz1dcXz4+0hBr5UFLIj2sUwOjSxB8QzDvEUUhXaGcwhbv6rgc7U+Tb0GBjF 6p/6rJILxQqZlGxWBYcmyNQYwaF3CarZU8LJilIOFmRUqZM0RyTZHBVBGIX8cHyNzYO9 blXx3ps5K35gmHkV/Snd0CBZFXXZWYRyyRyhN3UAFpvIaaRLH1asBmTt/l2VuX4B+lKJ qytbPpl3GX3pxxCMcs4CICvLXELtD/MQxokMd3oijDtqah+m43eO0n1T7he89kircvG1 RCqWgoQLDwi16nTQ3hhkqEvKn86HVSB+JsvGJmTn4nEGFcAhAuKMDEGE/PqkPO/jfFOk tHzw== 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=TA7DGMQCw19a83BY8nreNY/rrQakybzOsuCVhE1HSNU=; b=ZILUBnVCbsR1qnixAoESf1Sqwxk3EidEYorb+N0E/EeY/DFzbS70hNrSQvP+PQz+Ej 8nOnKfcfFns9Zg3u/0WwCVFRyH7r13VJYV9fIHz//Ihi9rFtnhbCkjt54Dijcincbrpb HgPwXa6QJ+g9oqt3XMlvNCGL6z/RSpXHbMlG7fC1lM8edhnCBQAmD/UtqvrFyYNBxyFv zzcOgpjv8TVw7j3aDLxpQ+7282JfWAAp/KuNaOkoy79eL1TFKipjsDhnxXiHpvDUaTDB 2A9kFOYrOuRGAo8pNkdO931LIvNClTl2i2dtoZ9aAXBfn7D5+jHvr74sQ4oPt+S2Oshq nO1g== 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 x21si5163624eda.366.2019.11.08.13.37.39; Fri, 08 Nov 2019 13:37:39 -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 S2388266AbfKHVhg (ORCPT + 26 others); Fri, 8 Nov 2019 16:37:36 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:34605 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388098AbfKHVhg (ORCPT ); Fri, 8 Nov 2019 16:37:36 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MiJIk-1hxgKI09MU-00fVGs; Fri, 08 Nov 2019 22:36:28 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, "David S. Miller" Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Willem de Bruijn , Eric Dumazet , Maxim Mikityanskiy , Paolo Abeni , Neil Horman , netdev@vger.kernel.org Subject: [PATCH 10/16] packet: clarify timestamp overflow Date: Fri, 8 Nov 2019 22:32:48 +0100 Message-Id: <20191108213257.3097633-11-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Pbh9bPUl2aqLHegsKvRFwZRv3Cocop6mYisT9cAEAqjy9WJ2fy6 UEpW8x2RFVQtu+G+dVwH5ICaDXq8iRjgi21pd4OXQ0FVy0ZJx9KJfMGHTgklUPQyr3z7BTo 2GkxOSDAcCm6BGiX4Iy0vpTySWhE1nI/6y4RP3MtLMZliq0iN6/OUuj/P18as7HJN7uVT0Q gJcxtFflpPIxSw/idl9dg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:y4QVRpvbjHQ=:TunfjY7qgL1v9cin2/j9nU 3LGWsCmTvT3gfa9SMUftuz8J36IjGWdRJm9Juvg1/pJojs7J4nyiAEmakQ9uBHdHcsucfPsJ3 HZWcT8EOWwtyiNUJ0e7WohuZtSjzNH0k/eR+O4OA1y6XOdfYblR+/e15ibItKEQfzNyMnAdbR SbkKzaPgEBSaCqjjsVPAeqzuKc2oDUQyH9F2aqjpAwxpfXm+HSQQ6nDzYBYHb7cOYrp10AjN3 bnv5grR3SEL8fWYa0LviYIqBWbxj1gvAk2qbPjrs4cwPoBaILy4ZJys+HRZmWOGB+okqfNrE9 ly2VvYSnt11hNNb6Ohn1jIULFNdsRBbWoDPAJkq91SkcxPFDdl6xfh2g91Rl0zGRjYx2h17/E UGmIvyfhtQ5TkKY5SoyB8kCml5fQYDMwqj4otLd1nApj6KU3yK5rOrsZsfn+7XBqg2AyQtzWq ToYMlnA0V3T4NEVrSSa9JoYgKhwObft2+60+ocYOstnSVnsQlMHM+CL6a8hBEv+UsoblK1IpM ld9EQqSSFRxnR2U7/6kfmjXLEJ0OJ00ek5J+5fk31900/LEkL/+zbZ9aavQBl/4OfuWQJiRG4 oJceiu7OfVrHTXsnJnJ1eJZUPqyfB2OcrNJfd/+dZfQbbfvthI8ezUHhTJMDTeirr/zDIXpdd e7Opd2AdmaCJYuBdoBkEKpvMSBtskWm7M7RyXAJNE9qcI5TeH6uHCYk2h+reFPapTock9gZJH uK8uAIySB5iZGLaE2c9Firh5vQsXe0PeG9XJM4tkvEe8NMDl7Zp2caYES6RMjNS9/LUkKisEG tWuHC307ihkEhayQnnm4tDMTLg9cwuP6ilvSGJzuDvKf2EqTn/fIVpzwJbIGiIRZs7R649kB5 L+1g7uJWOISvVJ5T/Bcg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The memory mapped packet socket data structure in version 1 through 3 all contain 32-bit second values for the packet time stamps, which makes them suffer from the overflow of time_t in y2038 or y2106 (depending on whether user space interprets the value as signed or unsigned). The implementation uses the deprecated getnstimeofday() function. In order to get rid of that, this changes the code to use ktime_get_real_ts64() as a replacement, documenting the nature of the overflow. As long as the user applications treat the timestamps as unsigned, or only use the difference between timestamps, they are fine, and changing the timestamps to 64-bit wouldn't require a more invasive user space API change. Note: a lot of other APIs suffer from incompatible structures when time_t gets redefined to 64-bit in 32-bit user space, but this one does not. Acked-by: Willem de Bruijn Link: https://lore.kernel.org/lkml/CAF=yD-Jomr-gWSR-EBNKnSpFL46UeG564FLfqTCMNEm-prEaXA@mail.gmail.com/T/#u Signed-off-by: Arnd Bergmann --- net/packet/af_packet.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) -- 2.20.0 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 82a50e850245..0bfdb07e253b 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -408,17 +408,17 @@ static int __packet_get_status(const struct packet_sock *po, void *frame) } } -static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec *ts, +static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts, unsigned int flags) { struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); if (shhwtstamps && (flags & SOF_TIMESTAMPING_RAW_HARDWARE) && - ktime_to_timespec_cond(shhwtstamps->hwtstamp, ts)) + ktime_to_timespec64_cond(shhwtstamps->hwtstamp, ts)) return TP_STATUS_TS_RAW_HARDWARE; - if (ktime_to_timespec_cond(skb->tstamp, ts)) + if (ktime_to_timespec64_cond(skb->tstamp, ts)) return TP_STATUS_TS_SOFTWARE; return 0; @@ -428,13 +428,20 @@ static __u32 __packet_set_timestamp(struct packet_sock *po, void *frame, struct sk_buff *skb) { union tpacket_uhdr h; - struct timespec ts; + struct timespec64 ts; __u32 ts_status; if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) return 0; h.raw = frame; + /* + * versions 1 through 3 overflow the timestamps in y2106, since they + * all store the seconds in a 32-bit unsigned integer. + * If we create a version 4, that should have a 64-bit timestamp, + * either 64-bit seconds + 32-bit nanoseconds, or just 64-bit + * nanoseconds. + */ switch (po->tp_version) { case TPACKET_V1: h.h1->tp_sec = ts.tv_sec; @@ -774,8 +781,8 @@ static void prb_close_block(struct tpacket_kbdq_core *pkc1, * It shouldn't really happen as we don't close empty * blocks. See prb_retire_rx_blk_timer_expired(). */ - struct timespec ts; - getnstimeofday(&ts); + struct timespec64 ts; + ktime_get_real_ts64(&ts); h1->ts_last_pkt.ts_sec = ts.tv_sec; h1->ts_last_pkt.ts_nsec = ts.tv_nsec; } @@ -805,7 +812,7 @@ static void prb_thaw_queue(struct tpacket_kbdq_core *pkc) static void prb_open_block(struct tpacket_kbdq_core *pkc1, struct tpacket_block_desc *pbd1) { - struct timespec ts; + struct timespec64 ts; struct tpacket_hdr_v1 *h1 = &pbd1->hdr.bh1; smp_rmb(); @@ -818,7 +825,7 @@ static void prb_open_block(struct tpacket_kbdq_core *pkc1, BLOCK_NUM_PKTS(pbd1) = 0; BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv); - getnstimeofday(&ts); + ktime_get_real_ts64(&ts); h1->ts_first_pkt.ts_sec = ts.tv_sec; h1->ts_first_pkt.ts_nsec = ts.tv_nsec; @@ -2162,7 +2169,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, unsigned long status = TP_STATUS_USER; unsigned short macoff, netoff, hdrlen; struct sk_buff *copy_skb = NULL; - struct timespec ts; + struct timespec64 ts; __u32 ts_status; bool is_drop_n_account = false; bool do_vnet = false; @@ -2294,7 +2301,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, skb_copy_bits(skb, 0, h.raw + macoff, snaplen); if (!(ts_status = tpacket_get_timestamp(skb, &ts, po->tp_tstamp))) - getnstimeofday(&ts); + ktime_get_real_ts64(&ts); status |= ts_status; From patchwork Fri Nov 8 21:32:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 179000 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3315841ilf; Fri, 8 Nov 2019 13:37:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzCiPrMh32Lsa4QU1t4AsqqaaF91vU7FwO00+dwQ0mWWK/G2xhPJLkca4yHxbXc/XnfL4s3 X-Received: by 2002:aa7:c444:: with SMTP id n4mr11418030edr.3.1573249077622; Fri, 08 Nov 2019 13:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249077; cv=none; d=google.com; s=arc-20160816; b=NTauqBLeMsRMF2iBMcFTdPpA8NdhySDPhFK9k4SGYytGhN0oFYZvxD5QuUvqAgeU9z zOYpgwQS8TnC6ZzO1hedVUAVBjhGHaYbi8NqfPdg8A2NpXDjJLBLvYBk8KyKpNg2zUam VXOethbnf8jp8ZDvULALT9dHyd2HXJ1RXZtaxDKKCLrvRpGt4KPVGerFmin7WDQnLhtG nvF2t6i3OlEAieLvp4X20LUkkF2F5j0L0GuB8UyRoCw7W7NMaeMPSF/Z6PEuJbZLSdBf PDNsgH7ADqIivbxrzBr5DmVG1k/xaDsVzgeFphufCL3hQqhJ5DR7wK2oPEpaCRsL42Px hfnQ== 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=kQiL/FY7jvLf7F7pMftdMkJVYyPxSrzwTcCiIL+ErRE=; b=p8KizCugAoFXzWi5ZZ6S9acs8VBhPIV89qS4SIGldCroAFSa8lxwYS2SNj6ici0kWE 1AtUFQRpukAnQOLX9is6etzG3UIh+BS57CinNljzkZ11t6h6x9KI5pOjC8jY7qZ0mzv4 jEcJkl/8EmlAlwUCmb6MkdI/A089Rx7OuJaeRKKpcr0pc+cqd2KIcVtlsisLTrFTqJtq PgTtj6XJSOlZu6SuDw46C2i7Le/gQmY5VHXlCbBOe/Wy+XF/0oZPSS0pQmr2IMBx3rON WaSG4vUEYC9BenxO60H3NUM5A3Oc4mEcLkdCZxTu2GGKWXviR6ISiV4ad4zgUE1yFQzt YSYA== 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 e24si4636498ejx.220.2019.11.08.13.37.57; Fri, 08 Nov 2019 13:37:57 -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 S2388386AbfKHVhy (ORCPT + 26 others); Fri, 8 Nov 2019 16:37:54 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:44267 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388098AbfKHVhx (ORCPT ); Fri, 8 Nov 2019 16:37:53 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1Ml6Zo-1i3mCK0AMm-00lWcq; Fri, 08 Nov 2019 22:36:40 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Jan Kara Cc: linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH 11/16] quota: avoid time_t in v1_disk_dqblk definition Date: Fri, 8 Nov 2019 22:32:49 +0100 Message-Id: <20191108213257.3097633-12-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:r4+HDTKLF8JwWwZoVSG61m2TMwB5tZHUr07N5j4f9snFYXaTdcY 8FRUSe43cL00EtG2dk4U1k+hXkV64fPxg7EX4hmJZQNw/AyESlLPHpAg25GkrUqXhPGl9Lx 8YRcLHUZLOSwT20wpqodE+JInhJy7d2FFkcfHTVzHy8N5ypap4xeBuCESRRynBQgUvk5uvs nmwdUOajEqKDJ2kcXErsA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:smWTcQrNlag=:uceC1aGHaQdFcGEu4mCRW8 IycRt3ysNIHQT9iNFSsAykKZJ1rvSzRVIec34YMmY2Q9Pt7HHRjxq72igB5ec/1Sx4cAcSV+F d7GMy2eAogNO3pEbWvgpZN2+J9C6XW53mlBhFobTyozqIVZbBJe5qwl1Ox3CRCPGjQD7utCvd fgBZnXEXE4/0nHRebGtVKyx/zO5RGk3LPRyodlQ765n7wjCEz7UZe5AuRLLi1GdF6yI3JJIEd v6I2XYkK2SXQo1+vQ2AS68rUMDjJF+AFyx7SZn51NQIk+pwg7/0uf929uYZHmWSVs35/6wm+Z MkSjpbm/rFl6ZXwOIUOw/FXsZ+ARRtv/uV2bmBEFQvNXYYKPknMdDdtSj+KgusKRxVsTs9F/3 gS1nk408LbTXOTk4a06htk6k7py7No6/csoOfK+ze5KocKp1MqQKUM8DheQm5DFVNfip5dF5I wZPQFkBD+te3Vv4Zc4VBNgeht9YyKqwneuRtYcFASSoGXkOCA0qwc5iTnEt14yynLkQFAMQEW txC3StDzJZBhfkyANjR4Jcl+IOEkEbhmJg1vWyGh64PffHxZ4V6R8vHh9W75QuPj/qXCqBH4D 9iozyL+1PLUi4m/gcpH8mAVJI+U2TXPvCCIykQiebBvN8oGx9B0Fj8WKr2BCSJJtGiMOmQfhg T/rB/hvlwqZlFe0vMnpDbSdb3cE0vAGj24u4rL6At5JDEvwck+qTU2N0zQzV2J8aPt5nOKVH2 ODZGHba3cEBb3FVrF/WKHrkDRUgd5isoiM0jRKBebve6rXhKVQInUy6A5J3AagYkUCdauqeK7 FQhtJvvV8hgtVOXFiuIoDEvVXNliECSauDatoMv6mTutAAfIv+jK1voP2I0TDbOqLVr7B1ZFG oZ4A1HVS+oWARNansHPA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The time_t type is part of the user interface and not always the same, with the move to 64-bit timestamps and the difference between architectures. Make the quota format definition independent of this type and use a basic type of the same length. Make it unsigned in the process to keep the v1 format working until year 2106 instead of 2038 on 32-bit architectures. Hopefully, everybody has already moved to a newer format long ago (v2 was introduced with linux-2.4), but it's hard to be sure. Signed-off-by: Arnd Bergmann --- fs/quota/quotaio_v1.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.20.0 diff --git a/fs/quota/quotaio_v1.h b/fs/quota/quotaio_v1.h index bd11e2c08119..31dca9a89176 100644 --- a/fs/quota/quotaio_v1.h +++ b/fs/quota/quotaio_v1.h @@ -25,8 +25,10 @@ struct v1_disk_dqblk { __u32 dqb_ihardlimit; /* absolute limit on allocated inodes */ __u32 dqb_isoftlimit; /* preferred inode limit */ __u32 dqb_curinodes; /* current # allocated inodes */ - time_t dqb_btime; /* time limit for excessive disk use */ - time_t dqb_itime; /* time limit for excessive inode use */ + + /* below fields differ in length on 32-bit vs 64-bit architectures */ + unsigned long dqb_btime; /* time limit for excessive disk use */ + unsigned long dqb_itime; /* time limit for excessive inode use */ }; #define v1_dqoff(UID) ((loff_t)((UID) * sizeof (struct v1_disk_dqblk))) From patchwork Fri Nov 8 21:32:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178996 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3314815ilf; Fri, 8 Nov 2019 13:37:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxx47Jq9uo42wRn9Jo2i71EUWQ2lUUV1FcHskEyD6EvwBUgVuhQLBnqZZiagXhhwa/Munhk X-Received: by 2002:a05:6402:1299:: with SMTP id w25mr12904995edv.10.1573249024167; Fri, 08 Nov 2019 13:37:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249024; cv=none; d=google.com; s=arc-20160816; b=wH4FeP7xc7sILBoWvT62wzDwReIEbO4igDdjOh9yjxIj8U7aUH/FU3nRleWqVoQEsn lOH605N5uLAuMG/pmKP+3q0a4r8/JTj6Ku0PBshsypqTTl1JEESMKQwQDrC72Q9BcdgJ FrTRgHuIDQSe3wZZnNejfajxPGsB6eJwewxW5oVBxs7wmaSVI5FA+1dsgsN1S+X4UIsd uxKOncqrfrEYgSyTzH2ToaXjyyxc4hjxi1p8TwY5yMYC9eRSlNE+NYMSlYdd05Twwwp/ juB/k5lPfY+CDfTpagouAkqUB4FJrdr33xdLCZOhZl7jAot9//2WBR8tvpHOVQBInlle UaRw== 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=NfunjSBVpvOoQmfqdLSCtXSk1ZF3a/a5p7wyetE7dyk=; b=NpGxAK5h4A7zIz9Z1LRir611kr4x3XCZteVLUtRiHV22qyXLbuQzkvU7avPOjE14jV ifOA8aTTMBg5UWvFuMjQSQpkFel1IQtixfLujWn2+ld17rLAXvJFKeV10xtezrspQx/b mUx0uCZF8Va37w2WeDxZQl0BOkLoZeZbC9Ps0zcb/QC0UiIx44/3kSXY/390hukUNa1K 2bfWghVat4WpBtx5b5PwoZZutFKhiXmdrEJUgKtK4Ez5KYiWRMB51P5B8BM5HhKAd9rB OiXiONj9Fz7mbQuJQHUXyCwuh5y0SiKlSY4vsX9wYaNMwG8Yq1oqs2TLQ/r9dsPUWOgd 8u+g== 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 g6si6086305edk.210.2019.11.08.13.37.03; Fri, 08 Nov 2019 13:37:04 -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 S2388081AbfKHVhB (ORCPT + 26 others); Fri, 8 Nov 2019 16:37:01 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:51629 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731097AbfKHVhA (ORCPT ); Fri, 8 Nov 2019 16:37:00 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1MXXdn-1iQ6Au3bOp-00YveV; Fri, 08 Nov 2019 22:36:51 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Jeff Dike , Richard Weinberger , Anton Ivanov Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Colin Ian King , Al Viro , linux-um@lists.infradead.org Subject: [PATCH 12/16] hostfs: pass 64-bit timestamps to/from user space Date: Fri, 8 Nov 2019 22:32:50 +0100 Message-Id: <20191108213257.3097633-13-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Yjh6blzut3U2WoiDT+9caZknQkgK1SpL5j185/SocENaX6KahaJ kOL/KPbr4pFe9IK4tNAPuqUZYc9vyuuRJlXa5Jyi5HeOeb/Mqnh0xCaFpV2rdvsfH7y4Wit 8UNwCPfTSY925fxcJvFdawPFZqCjcSfTBZkeg5nRD1wJtObhSfUCv5bW5Ua7XjmkI40iyLD p8Q5pHUIIqdkvM0JmOt5A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:s6RMSOV+IEU=:WJyWxBiIq8IQCJo/f/EKGK nqQ7zcAZIxMF8ulFyWM0BfYcrcDNkXlwNqouT+zyA+QDs28rWHJWnLUgU3IGZV6s4hn9NIDl0 og/Zgd7ooGGaFdG1Ixujt9uatHRtM/p2mXFQ3y9d+X6bDq2a10m3jJu5E/gleN/fStRntxfjt TMgfnaYURyOib+S2OXeg09KikTVqMiBXxamINr30VR6p4wxwrLGOLRpnoCi7B7FF/g2u7bENY Jc70Fs4f3erfgcfvzu5NszIBybVltfX5SoCJkff1nM1/30ycy0Ty1kUWdhDwaX3wzPcOSEaGv ieVmmTHqFpL+2pwStqHjQfThVawdeEKIp2qKX6AgWIPei04i26CNLIaPNE8OnWYR8xg5st6Ui DL9HNF09gu87sO0m45Ffair4klP3nAr52XsUhiOhuyw2orclqBQ7BZaiwqX8h4kCpBuG/RKvB 45a5ySGCzIdLNbrBSLXjQp3OEVCbz1MQI5Ge8KRvURLrxLta7mN3uzS/bZN/yTvYRrmKOQmrs T7IOnOzlgOFPYQFeQgjzjW/4QvQzTi89y/sUvSbuKgej0slGgyvW/kxi1XgEOIaW7Hxjimqua n1ioK5aaHnQ4KXmIrXS7zqnikJzS9Dh39KvWoghF0JfkXVGb48p3ZzlnoXOVb88BLqSHuiZsS cEoyEbpdO0HCKFTUMxuOFghzD6KBj0kA2D+PA7I79q7eI5gu5nQ5sL1Rp8XM8GWxbN45szYrL PLEQ5gOAnsfDyg0iatYRqpwrvGpSOPxHB64nYdAItsP6HnAa2pE0jWVQ1rWrOS5O6lgvy+XtC GdFBv5ySckoxO0DoPYjQrhQZRgsWnmu035Pl8oaOzX2VHdSJzmoxST9WIZnKK+GvPp4XwIF55 4PGIiv/0CL4yDVP7LC1w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The use of 'struct timespec' is deprecated in the kernel, so we want to avoid the conversions from/to the proper timespec64 structure. On the user space side, we have a 'struct timespec' that is defined by the C library and that will be incompatible with the kernel's view on 32-bit architectures once they move to a 64-bit time_t, breaking the shared binary layout of hostfs_iattr and hostfs_stat. This changes the two structures to use a new hostfs_timespec structure with fixed 64-bit seconds/nanoseconds for passing the timestamps between hostfs_kern.c and hostfs_user.c. With a new enough user space side, this will allow timestamps beyond year 2038. Signed-off-by: Arnd Bergmann --- fs/hostfs/hostfs.h | 22 +++++++++++++--------- fs/hostfs/hostfs_kern.c | 15 +++++++++------ 2 files changed, 22 insertions(+), 15 deletions(-) -- 2.20.0 diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h index f4295aa19350..69cb796f6270 100644 --- a/fs/hostfs/hostfs.h +++ b/fs/hostfs/hostfs.h @@ -37,16 +37,20 @@ * is on, and remove the appropriate bits from attr->ia_mode (attr is a * "struct iattr *"). -BlaisorBlade */ +struct hostfs_timespec { + long long tv_sec; + long long tv_nsec; +}; struct hostfs_iattr { - unsigned int ia_valid; - unsigned short ia_mode; - uid_t ia_uid; - gid_t ia_gid; - loff_t ia_size; - struct timespec ia_atime; - struct timespec ia_mtime; - struct timespec ia_ctime; + unsigned int ia_valid; + unsigned short ia_mode; + uid_t ia_uid; + gid_t ia_gid; + loff_t ia_size; + struct hostfs_timespec ia_atime; + struct hostfs_timespec ia_mtime; + struct hostfs_timespec ia_ctime; }; struct hostfs_stat { @@ -56,7 +60,7 @@ struct hostfs_stat { unsigned int uid; unsigned int gid; unsigned long long size; - struct timespec atime, mtime, ctime; + struct hostfs_timespec atime, mtime, ctime; unsigned int blksize; unsigned long long blocks; unsigned int maj; diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 5a7eb0c79839..e6b8c49076bb 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -549,9 +549,9 @@ static int read_name(struct inode *ino, char *name) set_nlink(ino, st.nlink); i_uid_write(ino, st.uid); i_gid_write(ino, st.gid); - ino->i_atime = timespec_to_timespec64(st.atime); - ino->i_mtime = timespec_to_timespec64(st.mtime); - ino->i_ctime = timespec_to_timespec64(st.ctime); + ino->i_atime = (struct timespec64){ st.atime.tv_sec, st.atime.tv_nsec }; + ino->i_mtime = (struct timespec64){ st.mtime.tv_sec, st.mtime.tv_nsec }; + ino->i_ctime = (struct timespec64){ st.ctime.tv_sec, st.ctime.tv_nsec }; ino->i_size = st.size; ino->i_blocks = st.blocks; return 0; @@ -820,15 +820,18 @@ static int hostfs_setattr(struct dentry *dentry, struct iattr *attr) } if (attr->ia_valid & ATTR_ATIME) { attrs.ia_valid |= HOSTFS_ATTR_ATIME; - attrs.ia_atime = timespec64_to_timespec(attr->ia_atime); + attrs.ia_atime = (struct hostfs_timespec) + { attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec }; } if (attr->ia_valid & ATTR_MTIME) { attrs.ia_valid |= HOSTFS_ATTR_MTIME; - attrs.ia_mtime = timespec64_to_timespec(attr->ia_mtime); + attrs.ia_mtime = (struct hostfs_timespec) + { attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec }; } if (attr->ia_valid & ATTR_CTIME) { attrs.ia_valid |= HOSTFS_ATTR_CTIME; - attrs.ia_ctime = timespec64_to_timespec(attr->ia_ctime); + attrs.ia_ctime = (struct hostfs_timespec) + { attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec }; } if (attr->ia_valid & ATTR_ATIME_SET) { attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET; From patchwork Fri Nov 8 21:32:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178997 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3314996ilf; Fri, 8 Nov 2019 13:37:14 -0800 (PST) X-Google-Smtp-Source: APXvYqy/C/rqgDr6cScwAhYSL37GFSd8igcBqZkzckIDyJeKdjJSjBAK0Caa18YXQmW28JdWdVCm X-Received: by 2002:a17:906:49c9:: with SMTP id w9mr10873585ejv.309.1573249034750; Fri, 08 Nov 2019 13:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249034; cv=none; d=google.com; s=arc-20160816; b=gOikWtdbwy2TyhuenGCI5qEwvpLYxlgnf52rgWnL8e9Hq8iJDRR/unlL2XdOdq+4yf F6vJdNSJ/rwJPdssZIrKXsVjkuucPPLE3ap3j9ad/Pa3MnIOhVc8u/NeL5itdcgyRkkq f/7k5Rg2Rgx5/wndYJc+lTFYV18Jn9RA/wkAyR02JRB3DkLD+5m00UKynlffGOkfDX4e ekZ3RtUEFHx7K3gk/bUXtuwfx/b0UlQeRYirMCYZJecqsQoY6een8aZyAlEsEJh6R93H P659bZHEzpPwvqnFvE3JPqVve/cKs0OUG8pK8cp/9mlKkifzyRvXAJjkUMNrXDpBtXon kBpQ== 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=tdcQVmlcbd9qVHHPrGolH7/kVZArJ1/bKcQKmaujOU4=; b=tjMmauV1StsCkEAZYp7Ce5iJnO6++fMrLclhAgP9Iu6ldcojj5QBbJZ0pGLPnGKXrB xcpyGmIoFJWfv6o4eebn26Kv7T4jAkzMBMei3cbK9GlRYy3718ZAg4x/QC+d8PKShBGf ykDi9vFRaObXXmxSYnMJ1hWOZ6vv+8GA8iREdN2noBeglJJMsTNlZ2Oq7TxSBt2O8UZf vXrAeq9JjfwAqiK+qnEvDdNIehsiYBqNMqO0GA/dwkPD/WRKC2Tki4QyjCPgw14+pLwW UGHcDwXGUYBJjxMC54ANiGfvfBfAfrXJhwBAM/acSWEH12rgRNRela8ze2RevCVyOt0j zEWw== 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 bi3si5494456edb.331.2019.11.08.13.37.14; Fri, 08 Nov 2019 13:37:14 -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 S2388171AbfKHVhL (ORCPT + 26 others); Fri, 8 Nov 2019 16:37:11 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:60559 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388098AbfKHVhK (ORCPT ); Fri, 8 Nov 2019 16:37:10 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N1x2P-1hmtCN33vd-012Dzx; Fri, 08 Nov 2019 22:37:06 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Viacheslav Dubeyko , =?utf-8?q?Ernesto_A=2E_Fern=C3=A1ndez?= , Andrew Morton , linux-fsdevel@vger.kernel.org Subject: [PATCH 13/16] hfs/hfsplus: use 64-bit inode timestamps Date: Fri, 8 Nov 2019 22:32:51 +0100 Message-Id: <20191108213257.3097633-14-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dFOmQMTQtnWEyRN1FoOfYEBxuK8+hd8DreubJy9bt74CPr2b+nd vT2+1QEmWCQGca4MDg4bRywB1F/gzNzmBGqy3NiCvcbAEyDw7ZB0fHGUp650Fd4r6MT0C6E irwn6c/ra7H+2MDw0UaK0CMmc/ers51foyfk7oY8kkdokn7V3DBBFxf43lLxBOFTeFp5XAB RvzzR3L0+ww7/uSh5kE9Q== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:hJaojAvmzhQ=:owmkYgBYYh01+71gpm17fZ CnVZxG2ABiDYuoiyq2v7zUBtcJC3nGaOf+ipNAwmIr4MiR4vT744PnD3T6V2A+esxyVHhXhLg Z5dJzygp7izpC/QiooJhTPTcPg9WTFhkhYNjSpM+5iYKNZqI5cUbLLq7EWd+4HeQWgCwkE/XR itOW8aawVHIVLCtS6fM+qJ5VzpPia4QxxpgaJVUqmgBfX8Q9kRXjfqOW/IZlBu+uxZ/pGd3Rc xTsOVil6Jyb5gYoIVRNyWSAyO0+JWdsjtpNi2lQ8zdnZh3uJGMaQ0ncAV1tOlzb2HOnvy1EDU hSQILNs8dEMrfR0UdBk33b3CQhTuvUfaLtjzWLjc+vGkwEzLFlPcSpMrbjjP5qYCtgThV50vd 0kchu6ER/Inq2tsfCiIda8tKREzCTbz6vy74nX34dSfSQ+xk+bi8KZwgTyj2vsOoScbMJears 6/DOdonQTq4ANbRxijkHVbzeQ4FJisKDA7LIzmj9DJxVOI5wY8+rO41/YS6QKy0z7pjxRJbIX mac0zTiWzZL27TPDd65cQCc4K8lov6drjhpA9km5fVm8Mn44HubxZ52RDXiKNMSIm65XseCyG 8dFA/RSlYzaXm2ddEAbJqgmeL7aP0SaK3inWdKyg11rmtpjnnsEw1miD+q7rBAEFTt1ltFr1p tzIkrK3C59unnN6V23mQaAqw//YFGBwYVcT23MKU1Io6Kwhbt9WDD/uul1YwQHLPE7Hdicux+ o6ME5gXQL7E1pOj+uxqvIfUDQFQ8jXW0bgA6r442QaJJ+31gcFQ9fNJ4iGB2mFq6g5ym9D0X5 OUQpRWv6N4gC+JrYMhB0mfaVUHEyPXnGFkd854qkzes9mRdywG/9TamroKQ6DSEFxoVD2FVld Ztz4lVnETJRAJ/uIIqjQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The interpretation of on-disk timestamps in HFS and HFS+ differs between 32-bit and 64-bit kernels at the moment. Use 64-bit timestamps consistently so apply the current 64-bit behavior everyhere. According to the official documentation for HFS+ [1], inode timestamps are supposed to cover the time range from 1904 to 2040 as originally used in classic MacOS. The traditional Linux usage is to convert the timestamps into an unsigned 32-bit number based on the Unix epoch and from there to a time_t. On 32-bit systems, that wraps the time from 2038 to 1902, so the last two years of the valid time range become garbled. On 64-bit systems, all times before 1970 get turned into timestamps between 2038 and 2106, which is more convenient but also different from the documented behavior. Looking at the Darwin sources [2], it seems that MacOS is inconsistent in yet another way: all timestamps are wrapped around to a 32-bit unsigned number when written to the disk, but when read back, all numeric values lower than 2082844800U are assumed to be invalid, so we cannot represent the times before 1970 or the times after 2040. While all implementations seem to agree on the interpretation of values between 1970 and 2038, they often differ on the exact range they support when reading back values outside of the common range: MacOS (traditional): 1904-2040 Apple Documentation: 1904-2040 MacOS X source comments: 1970-2040 MacOS X source code: 1970-2038 32-bit Linux: 1902-2038 64-bit Linux: 1970-2106 hfsfuse: 1970-2040 hfsutils (32 bit, old libc) 1902-2038 hfsutils (32 bit, new libc) 1970-2106 hfsutils (64 bit) 1904-2040 hfsplus-utils 1904-2040 hfsexplorer 1904-2040 7-zip 1904-2040 Out of the above, the range from 1970 to 2106 seems to be the most useful, as it allows using HFS and HFS+ beyond year 2038, and this matches the behavior that most users would see today on Linux, as few people run 32-bit kernels any more. Link: [1] https://developer.apple.com/library/archive/technotes/tn/tn1150.html Link: [2] https://opensource.apple.com/source/hfs/hfs-407.30.1/core/MacOSStubs.c.auto.html Link: https://lore.kernel.org/lkml/20180711224625.airwna6gzyatoowe@eaf/ Cc: Viacheslav Dubeyko Suggested-by: "Ernesto A. Fernández" Signed-off-by: Arnd Bergmann --- v3: revert back to 1970-2106 time range fix bugs found in review merge both patches into one drop cc:stable tag v2: treat pre-1970 dates as invalid following MacOS X behavior, reword and expand changelog text --- fs/hfs/hfs_fs.h | 26 ++++++++++++++++++++------ fs/hfs/inode.c | 4 ++-- fs/hfsplus/hfsplus_fs.h | 26 +++++++++++++++++++++----- fs/hfsplus/inode.c | 12 ++++++------ 4 files changed, 49 insertions(+), 19 deletions(-) -- 2.20.0 Reviewed-by: Ernesto A. Fernández Reviewed-by: Vyacheslav Dubeyko diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index 6d0783e2e276..26733051ee50 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h @@ -242,19 +242,33 @@ extern void hfs_mark_mdb_dirty(struct super_block *sb); /* * There are two time systems. Both are based on seconds since * a particular time/date. - * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970 + * Unix: signed little-endian since 00:00 GMT, Jan. 1, 1970 * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904 * + * HFS implementations are highly inconsistent, this one matches the + * traditional behavior of 64-bit Linux, giving the most useful + * time range between 1970 and 2106, by treating any on-disk timestamp + * under 2082844800U (Jan 1 1970) as a time between 2040 and 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) +static inline time64_t __hfs_m_to_utime(__be32 mt) +{ + time64_t ut = (u32)(be32_to_cpu(mt) - 2082844800U); + + return ut + sys_tz.tz_minuteswest * 60; +} +static inline __be32 __hfs_u_to_mtime(time64_t ut) +{ + ut -= sys_tz.tz_minuteswest * 60; + + return cpu_to_be32(lower_32_bits(ut) + 2082844800U); +} #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_u_to_mtime(time) __hfs_u_to_mtime((time).tv_sec) -#define hfs_mtime() __hfs_u_to_mtime(get_seconds()) +#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(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 da243c84e93b..2f224b98ee94 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; diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h index b8471bf05def..22d0a22c41a3 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h @@ -533,13 +533,29 @@ int hfsplus_submit_bio(struct super_block *sb, sector_t sector, void *buf, void **data, int op, int op_flags); int hfsplus_read_wrapper(struct super_block *sb); -/* time macros */ -#define __hfsp_mt2ut(t) (be32_to_cpu(t) - 2082844800U) -#define __hfsp_ut2mt(t) (cpu_to_be32(t + 2082844800U)) +/* + * time helpers: convert between 1904-base and 1970-base timestamps + * + * HFS+ implementations are highly inconsistent, this one matches the + * traditional behavior of 64-bit Linux, giving the most useful + * time range between 1970 and 2106, by treating any on-disk timestamp + * under 2082844800U (Jan 1 1970) as a time between 2040 and 2106. + */ +static inline time64_t __hfsp_mt2ut(__be32 mt) +{ + time64_t ut = (u32)(be32_to_cpu(mt) - 2082844800U); + + return ut; +} + +static inline __be32 __hfsp_ut2mt(time64_t ut) +{ + return cpu_to_be32(lower_32_bits(ut) + 2082844800U); +} /* compatibility */ -#define hfsp_mt2ut(t) (struct timespec){ .tv_sec = __hfsp_mt2ut(t) } +#define hfsp_mt2ut(t) (struct timespec64){ .tv_sec = __hfsp_mt2ut(t) } #define hfsp_ut2mt(t) __hfsp_ut2mt((t).tv_sec) -#define hfsp_now2mt() __hfsp_ut2mt(get_seconds()) +#define hfsp_now2mt() __hfsp_ut2mt(ktime_get_real_seconds()) #endif diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index d131c8ea7eb6..94bd83b36644 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c @@ -504,9 +504,9 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd) hfsplus_get_perms(inode, &folder->permissions, 1); set_nlink(inode, 1); inode->i_size = 2 + be32_to_cpu(folder->valence); - inode->i_atime = timespec_to_timespec64(hfsp_mt2ut(folder->access_date)); - inode->i_mtime = timespec_to_timespec64(hfsp_mt2ut(folder->content_mod_date)); - inode->i_ctime = timespec_to_timespec64(hfsp_mt2ut(folder->attribute_mod_date)); + inode->i_atime = hfsp_mt2ut(folder->access_date); + inode->i_mtime = hfsp_mt2ut(folder->content_mod_date); + inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date); HFSPLUS_I(inode)->create_date = folder->create_date; HFSPLUS_I(inode)->fs_blocks = 0; if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) { @@ -542,9 +542,9 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd) init_special_inode(inode, inode->i_mode, be32_to_cpu(file->permissions.dev)); } - inode->i_atime = timespec_to_timespec64(hfsp_mt2ut(file->access_date)); - inode->i_mtime = timespec_to_timespec64(hfsp_mt2ut(file->content_mod_date)); - inode->i_ctime = timespec_to_timespec64(hfsp_mt2ut(file->attribute_mod_date)); + inode->i_atime = hfsp_mt2ut(file->access_date); + inode->i_mtime = hfsp_mt2ut(file->content_mod_date); + inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date); HFSPLUS_I(inode)->create_date = file->create_date; } else { pr_err("bad catalog entry used to create inode\n"); From patchwork Fri Nov 8 21:32:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 179002 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3316443ilf; Fri, 8 Nov 2019 13:38:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyIr2Y5EKe7NklbJ6QrSPSevCUczNPJpCmF0jdZs5DOFEFZNaC7OgLNDCflSSugu0N6/Sbe X-Received: by 2002:a05:6402:713:: with SMTP id w19mr13050806edx.239.1573249110696; Fri, 08 Nov 2019 13:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573249110; cv=none; d=google.com; s=arc-20160816; b=lrj5uSnpoiuJJD8eUKUf848z5eYkAhiIVURrvn59qIYwL4dXwquFZS0lDLshwuGr4Y 6wATZqIM/HQ0IlKZPxV88KgyHpN0elapJ/uKp5zuhaH1uLNqTLQHPghbQ0H/lgTsBGwp XfI6DIjcjZNYQ8drJx+FIxntmyEHm4VhlVluHiz9Cws9FXr3AdE5H4I6n7GvWNllXhxU nVGh5SNtN8hTy1d4q2Ka3iXbgH5Lou4rvlWcXvDTSkuIh6aPpihCvTrJIhcjCIh5gxPG G0MDu3JMK3eGBdCDEdsAVxLIJ1MchiOjlVXKjr5WPDHsuZqlRQfagp4jehMLvYandW1n 5BMQ== 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=lpdQWKdDrOPtx3R/NC5nwe7J1uH5+RbEM2cIVGKt/So=; b=uBwVZwWIrE0+mi2SqzL9ChEmerd0obE3Rx57Ryk5vkFBMlkYjAM3mNK497IxXgGSlg 7QcEnFrB8pwytNJ1x3PCv0DO/pZeY1yfTpubjtVNbrdxnwhKZ42bk0R4QokLBBHhvTuu Mp/C9ZLQPihHd0MabcpnOVS80Uqs0JY7qGuQcwqiboVe6EZtxc+K5YJmhWpY92HllcXl kSEyptnpSY2zUc+J38PkZUsa+5EYeVZSVsj0zodLlPNgGHqdmgZ+U2nrvMgubhkOcL6e EzDC+nXtCJ/K4I2yut97b/TRoZijVaP++QmknZ+M76lkjL9N+ssyZRMvX8RehiIsXUxQ AEzg== 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 t17si4604972ejj.144.2019.11.08.13.38.30; Fri, 08 Nov 2019 13:38:30 -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 S2388525AbfKHVi3 (ORCPT + 26 others); Fri, 8 Nov 2019 16:38:29 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:43755 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388444AbfKHVi3 (ORCPT ); Fri, 8 Nov 2019 16:38:29 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.129]) with ESMTPA (Nemesis) id 1N0WwO-1hfVjv2o8i-00wTtI; Fri, 08 Nov 2019 22:37:59 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Stefan Richter Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Clemens Ladisch , Thomas Gleixner , Will Deacon , Greg Kroah-Hartman , Richard Fontana , linux1394-devel@lists.sourceforge.net Subject: [PATCH 16/16] firewire: ohci: stop using get_seconds() for BUS_TIME Date: Fri, 8 Nov 2019 22:32:54 +0100 Message-Id: <20191108213257.3097633-17-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108213257.3097633-1-arnd@arndb.de> References: <20191108213257.3097633-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ShTMGp4lVNVsHj+KLbB1IsdO5sH5jn0FUtExiYeIktC9NBhPH68 Eo6Di/s4x1/c0s0lLRtXEL3+pUqH2jXe+lTpS1u0fj9Wj5g2hSZfutPCDmz9vVx1gkCHN+t lGkblZXmLSCwyqit9GXFDVWTAAGNnFLncfw6TYZEMKhOitqIsxr/7PMTbimFz3Ksb8vTWOR lcjupetSVcK3O/vCeAMtQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:leyoQLNXbQg=:XqNTH//TUd2wRfId2+/xfy eQ+WZQp1hTDWEnjaAb3rr/ypuDM/uWEbbd+ht2cL4NNSBam+Merhk3GCl8f9Na4vCuujDmXp8 dTjKewx5lcZM1j2vniPAnG5tRQtmf4DXuVdbRTg/AJW7r2nGu5oaik/cj+FLrQALbLu5W3S2g gn9HXG8FzCIFPb/yCthoolqyFw1m2CxJZI9yWZgM2EqbmeJkf1nAHcVCMqKOF6TCy1SC0r0pV YnTSdvXiIpNhzoHR2kfebW4bI7Jj+aN39JoSq370yilI8ABf3QPD/FULOrAElxyBBCVnigEUv qCDQH5Lo1X/AMa0go2UF08ZtuZ3WfXhE9/ULxTNV6KqnBU6W+jSU1tyAJtszmDnwmNIi6v8si jSBExJE9oZ5quHrJTc9DZ577cTb/GNuAJUDmoAub3HEkdJ2KxO5YZI0PUcsG22ysKX/+U0i6C 0meZYkHhON7G/I6cH0I6NivXIWpO7MNRerECpI5I5D4h5NGqscYeORHflrzpCI25c9GxtLPQJ JgpoygF3V4/4nBEOZTUOYfpCRWcaWMe+ZyAt/gYF5GRy5WAU3VETV85RWCDjhPLFKp2LvhP8I BZDS6CJDy7h1TOWLwOBMIGvM5bLAayvlR1dex0YsaPLpEh1b22ozGKQF8+DrZy42ok1EDxLpJ SJhNU7KVWt3RglSABWD8Pc98EBImv87rsCwacFTUKL806Y2GIsiTq/6DqDKWKsih4BhsCtQax TV2lC6jZ38zsEPk/ETTxzKlYrkyogQt7gehGY9ObecJ2WRR+9e6JIM0XpYWBTEeXkZLIY2mLc Kn/cN2Ga7qkgoMkPqDxRkgz/aavM11Cuw+uzN2F84JYcYiOLXxXTBZLQ5pqciOre7GWcnWYXf 8sV8mV4nOIfQV8FMpaVQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ohci driver uses the get_seconds() function to implement the 32-bit CSR_BUS_TIME register. This was added in 2010 commit a48777e03ad5 ("firewire: add CSR BUS_TIME support"). As get_seconds() returns a 32-bit value (on 32-bit architectures), it seems like a good fit for that register, but it is also deprecated because of the y2038/y2106 overflow problem, and should be replaced throughout the kernel with either ktime_get_real_seconds() or ktime_get_seconds(). I'm using the latter here, which uses monotonic time. This has the advantage of behaving better during concurrent settimeofday() updates or leap second adjustments and won't overflow a 32-bit integer, but the downside of using CLOCK_MONOTONIC instead of CLOCK_REALTIME is that the observed values are not related to external clocks. If we instead need UTC but can live with clock jumps or overflows, then we should use ktime_get_real_seconds() instead, retaining the existing behavior. Reviewed-by: Clemens Ladisch Cc: Stefan Richter Link: https://lore.kernel.org/lkml/20180711124923.1205200-1-arnd@arndb.de/ Signed-off-by: Arnd Bergmann --- drivers/firewire/ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.0 diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 522f3addb5bd..33269316f111 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1752,7 +1752,7 @@ static u32 update_bus_time(struct fw_ohci *ohci) if (unlikely(!ohci->bus_time_running)) { reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds); - ohci->bus_time = (lower_32_bits(get_seconds()) & ~0x7f) | + ohci->bus_time = (lower_32_bits(ktime_get_seconds()) & ~0x7f) | (cycle_time_seconds & 0x40); ohci->bus_time_running = true; }