From patchwork Fri Dec 13 20:49:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181580 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1141748ile; Fri, 13 Dec 2019 12:51:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwB3J3dXoSkGjaa7jh3lGLd9jDG1/Fn9y9cAQgPXcwBr9fM44yC9Jn/g95WRQiaYI6bOC0o X-Received: by 2002:a05:6830:1bf1:: with SMTP id k17mr16490934otb.101.1576270280672; Fri, 13 Dec 2019 12:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270280; cv=none; d=google.com; s=arc-20160816; b=UeIuQy/HB25BWKUVWYfc8jUgQ8QdDE3wBoPcV3VIM/eRbZ9oXAxuBcurSObgdA6R3F cQahI8kQQ0F4g1sGiDE8qICFoAlPox/+KU5ikN7YME0bxan8ZVlnMPxfCR9+UMhEdn75 LWVlgS7pTg6P8pFtHqVVafsEDM+hf/W77Tgu7CDsjLDtA6Q9fd30QBDTWxt83W9soUu+ F//bpezW1NWpd8e8gHgV9U2BfN8N5lWbBlAt6WazXOVsP1I6o7uI4K8cGxqqXhZf08Aw ewC3e3sysVnaYkle8MAkB39swcho0YEiTCruemRl4XRR+bxMWGRT4Hf1PUMuZbueY12x lD6Q== 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=Md2R45SQUUbGEMbZpUIeTBo2WS7/Yz86Vk4O3ReF5+jp++IwBWKAG/gH7coH6UqkoO qg2HNqopTMYCVeyXOQeEQQNszf9yoE5XWtNFjK9+rF0sbrBnyBKDs4TQkaxgoCkPHIsX ykOwtq24Z1UAGY81vET2kgj/7IGqPZevnbbZYZW58XO2AUYFGOeikGRUr8EQEx26RYmk M9dVuPnukWufAd+546Lm7Ege6H2tDrr7yQJmnPGvUwfsogv74Hq3sYwznk8y1HYjt6WT 86ZJ87BvkJGHQe8oXtNTYkfu36w7bA1Rd9XENqt93Naeg9fS0T5zXir+bVCPy+2yy3Tq l8SA== 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 l12si5856034otj.30.2019.12.13.12.51.20; Fri, 13 Dec 2019 12:51:20 -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 S1726708AbfLMUvT (ORCPT + 27 others); Fri, 13 Dec 2019 15:51:19 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:52363 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUvT (ORCPT ); Fri, 13 Dec 2019 15:51:19 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MbAYo-1i8iwY0uVc-00bePy; Fri, 13 Dec 2019 21:51:02 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, OGAWA Hirofumi Cc: Arnd Bergmann , Carmeli Tamir , Andrew Morton , Sergey Senozhatsky , Al Viro , Thomas Gleixner , Deepa Dinamani Subject: [PATCH v2 02/24] fat: use prandom_u32() for i_generation Date: Fri, 13 Dec 2019 21:49:11 +0100 Message-Id: <20191213204936.3643476-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:xom8Rv0Mro1nWgzFI7iwDzUBn2boE9thbAKykOAb1L7RRT/epwZ VtM23PMG6pgOlizw3iul83/tWNKoG5HNRt2I+9OXTnAPKKtbuCDdVXh2UDdHxO2S/xIbgzW 4+mc4R/82Uw/PvlQTQMe+S+3ilRTJvxa6AUa/tfMQHTuafSdfF/5NUHHtM1MGAUJw8gsQIs UxGzoDSg1FQTzfyIq7PSw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:W5FzphDL8cs=:g7EVKCCCGWuKFtKBRF9gl8 9ubOMCgpBznyRwkBiOr7kw4trZ5LWiLLP9bjkAkR2VaRCdGETpAfxLZfkex3O0CdFNJqjCEtV 7/zVz49UECoZLXBZvVjv5W+fLnyFepmJiw+iX3TTnY2anXbDyEyi4qBOIauLeMtrS/LOtjIrB vjBjzgmCqSl5CliXferQgt83CkH8JlEIxHKb9lpp7JM3tKpYsbGjfD1gT239kNx5QVETRORPt +MCvYOTgSaAhzVhDOBUEfZdMgJ0yX1Ub6IKdz+SEh5vpKDLkbe94yWNIhgyeV7/tiZzzimPEt l7JpAZGx0bonISGsSi/j+cZX/HxM9PvzXnd9aBywC+Axz/Is45PP+jRQB8eiPLS186foq688+ pc1Z9yU7EDdfUOKBLDc+rzNuJqibKATkixOCW5/2NEhjxiq+RLwEHuA82neI5PN2YPj++T++P KJ9EcWJ1deS52sKQB+rni8OWDhQFbxnK75aicnSWhRVMbC0i+1uSnBA5AW7KPVv6qrC5Qpu0o rr0JynSM/wOH+Ka5BgbF5fKzCKgEkk8/h32wVFvVN4NVGG/3p14B0Va34OtAvTZc91hnqxshG 6fZFZI1nc7qtGAwT8Ky60OSq5IXiJMkRJWjYgH80WjZRi9s8RWI4t00jbblBDF8TsdMJppCIb 8f0aS+NQHjiSTSmPZY0Prio7a3FiAOFz5xJk1aqUcPIwyhuevd+QmNjPlsUXEI6YxM+KgoUB1 axsNHR6KqKYpLnwS3Er0g1SM+D2d5AuyYn2cJzrnauWBysHSs6F74qYdUHa3KlVX9K0WyPNHh mN+q5uTRENovsB9aa6ET4aibHQ6iFTEN6vVfVgwkmxAZ0cVYBM9SXjZM9cTwAR3YifnyK8NMO tBIWDES2L1KyB7GHSA+w== 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 Dec 13 20:49:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181581 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1141823ile; Fri, 13 Dec 2019 12:51:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxIkqe7GV/6MrxSQYWsQ0g3QlcjzNS/HALFr3ruuqdNPWfCTD8t3CIOxqx+Qjd0ILIW63jq X-Received: by 2002:a9d:69ce:: with SMTP id v14mr10605362oto.248.1576270286107; Fri, 13 Dec 2019 12:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270286; cv=none; d=google.com; s=arc-20160816; b=GFkisMIjFJWawlX7krGlkR/LRfbunNuxQ4JAbKY0An6YWNnMCZU6CPR9MhP+z1hbqZ mJeR1SRRdjIT+BFjeq/2rNy5EDRRQt5AoAOha442NNjxYlD+Jm2mcS5tEp4EPpIjzxp/ B1RqVEqubZfD0Th0zv8n7UfOZh7g6gTy+4nlYG3yPvBX4QbAMN2OdjQ/Bzai+zbpjffN Hsly49GPaPbE/M/BPaoOJdJ6zwfUBOFhFZZe298JfBBskHHvNyxOoeRG5EB3UVYH24iZ 0xoK6mYevK/JIxFflWLxs6rbXkSUZ7mKuaGXfjJM1WJ4tXSGizQyHsJQPVi31gpAtyeX nA3g== 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=Z6CYDNhVNYFS2rdUBedw2J8pFSsRcVA1I7w2XeAo1Ss=; b=zSZgxhDtB7AXwtvQ/2R6Ank3FSTO2Tr25KpRNU1MQas90MmJ4JdTHxslWl0M5mqp7c Nat1h7G0t4F5PVxPL1eXpdYpogy5iEULGLVcbMzxNLBrPUfMCCtZQnWnHwtIMZgWT5ht u1znZ4fwsdr3GRE9+tBlyN+ji6JT3uBz66T/1iu05GD/CV8+LSJZ/ire45s4g+web2sy FUvIQXgbhf+hPVVdOz1r2PG9yY1hWGdK/nTilzfr4CBstoQIE4SMxvyfb07mRiRLy9bZ qzMfFHtg0SsTuRoevRVar5jjvEyi6rYo6zOMc9/Qwi0DmeSfGbVSgLCjOZ8ghTrzYNO7 O9sg== 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 l12si5856034otj.30.2019.12.13.12.51.25; Fri, 13 Dec 2019 12:51:26 -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 S1726743AbfLMUvZ (ORCPT + 27 others); Fri, 13 Dec 2019 15:51:25 -0500 Received: from mout.kundenserver.de ([212.227.17.10]:59363 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUvY (ORCPT ); Fri, 13 Dec 2019 15:51:24 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MyseC-1hjtrs3ojy-00vwQi; Fri, 13 Dec 2019 21:51:15 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Christine Caulfield , David Teigland Cc: Arnd Bergmann , Deepa Dinamani , Richard Fontana , Thomas Gleixner , cluster-devel@redhat.com Subject: [PATCH v2 03/24] dlm: use SO_SNDTIMEO_NEW instead of SO_SNDTIMEO_OLD Date: Fri, 13 Dec 2019 21:49:12 +0100 Message-Id: <20191213204936.3643476-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:JgGd8/iX9DERj/M5iCtB2a26MaoOZ9mjFnqSnunVh+f26nRMB2x LJwHidIBih58zaeiqD+QWZvmjmJvr5LBgkn4Oc8KHhhUGMhjVldx6278u3WX2GeGR9jv0pY CNJhdcI6Y0D76LueyfFCHDEKlSN3sWitDbT8Z4iI2W7uq7ARkybx5Zp6VhwMbIjrgBJzTxZ WQkKtr7kPtxyMi9vGaZdg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:tYDJc1dkaTc=:tLbuj+9nUfY1i2EKGWn7GZ asfdqauWEzm2ka5/EYjlY0E9PbE8iOKaSbLg2BFxOKsfiJQIGvd7X+Z/6Qvnf+wqY4oVBdYK8 iTCFvER5Xc3h/QTte16lPmsHKvV6H/U3Psa1A/kdDQhwIsxA0Yf1vzGIIa0Ykyy3uqwat+spS IlFK1EExs+ln1uqESiCFvCQz1a73wVOpOCTFtIoPjfgfE57XOtJ9WVXHD0KSLuhMAUDb6aYJu GI+/JftgWouszmdndBdpapd6kQM5r4QwqMR22GQH5gdaKNQFogidIwfofy8Abc3xU0gDnK3RW kM5bacedZQiRpjSy8qX5U7VQGJkk8RtVIpmqB5YDmF9T148xPhkuFfYaB5nrhNM6wiunjhiQi 9L7iAC42YiZGX8O2UbYN+TYJD6hxF561Qthbs/RG0g3u1gibbhfmsg0TH7wgzQo88kTtVIyws nNS9SXYeBYMZQRZkmIJrOAwY4ltzBqXZx6/meGWXhGtNTh7A3HYnJbLXa7vR5asmcJkzY+utF 9mwmZndOfA0HZ+UnZR0P1hrTJ31aUgHKcDanBJNVWEjH9wQgUkhiqBMDNeKGWHaguGGp4vxJY slemB5GF87BacNA4Au6ltVXAUEcpiivAJDR1G1xCjD63y80AoES2khvMsM6u7K65nV6e4psNy +y70+iddiCoC39+SN3p8e8vjpa2gn6H7NDAjjT+lMolE40SVsJHsyxsxwgYid1qe7vkDQpBtF QOxn5+ej3Olx0Hp2eLz+P2K0ROVJYA/yYmm9RilFnS+XX31lIcQpaTCuOP2Lt5vd+RR0b61a8 Z72PP6//0lRcQpMqV0qf4c+yhrdi3u7SNe8WGRKWjeZuOwFdfwaI8/Qapw1NfoZLLHEHjH2RY hb59rbY0ZGX73P63fWuQ== 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. Acked-by: Deepa Dinamani Signed-off-by: Arnd Bergmann --- fs/dlm/lowcomms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.0 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 Dec 13 20:52:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181583 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1142715ile; Fri, 13 Dec 2019 12:52:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxz/B25Rf0Tw6mpz5XbtCbuv0ySi2LBBPLKIw1Ze85DiHBZ0kr5WfUq8/ag1IAefzWIKTvs X-Received: by 2002:a9d:22:: with SMTP id 31mr15993510ota.173.1576270345864; Fri, 13 Dec 2019 12:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270345; cv=none; d=google.com; s=arc-20160816; b=q3x/XrLYfs3Bbbqc5My+zw/uOtdoyokSbIOjsMHoNFMtXlShvlU/RhsejolG52H3RY SevtNkg37yC96fBLqoohbwgrzfOYqV9th1geUbsOrNOlVvQ3ZTBozvCAiRaTuTtqq4Dq S5wxX7eAdHldZl5F9UrBvkDX+WKxm+bheDD4idEYMxV7INH79QDCRB7sVhwm8wE7F/SF TvJnt405t2lEr6v8omfghWsJPytEz6ZPBdCjcXEzHyjcxT8tm6o3WIDN4V0QEUAUsUav y5A4vabI+am6b+5CgpmtoXs26RxviwJOrvUorotaEXhZI+kQfUOTtCmq9f7Jhgyefz01 Ir/g== 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=XHbHc7ICBtVvj1Mn0I70Ea62wBoJXAzo2a+K/iHxzIc=; b=ykO9fvKSLtXncI9IziXOHV4rMV0Tagir82X4F9ollQHc2Rquwm9PUP58tysP5j4z73 30BGEskq2MZTwnmB5Trr0kt9nus5DDVtrExyKOjcm4/wA82aRAd1eCj7QquT0fsHn/je yuoG6MlibpcPFS684qZfSLaUdM035+xOHVd6+8gLZb7dmZRTPbNGCHO14eiArVjjTqS6 F72thr7jWUf0ReoPmwljKzYyjaf1XLvgt5qoRTljyc8DC6z2GsgUrDB9hZ521ARNv4C3 0QEP7Lesyr/u+Uow502qR4k9whICkKPchAhYBvXMi2PLyxNVjw3XXwVTfD8YwxeZ0ss3 qOYA== 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 m2si5472936otk.122.2019.12.13.12.52.25; Fri, 13 Dec 2019 12:52:25 -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 S1726642AbfLMUwY (ORCPT + 27 others); Fri, 13 Dec 2019 15:52:24 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:37891 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUwY (ORCPT ); Fri, 13 Dec 2019 15:52:24 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MKd92-1iRUrq0e6u-00L10R; Fri, 13 Dec 2019 21:52:22 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Chris Zankel , Max Filippov Cc: Arnd Bergmann Subject: [PATCH v2 04/24] xtensa: ISS: avoid struct timeval Date: Fri, 13 Dec 2019 21:52:09 +0100 Message-Id: <20191213205221.3787308-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:bon56UreV7ovrfKYpDHiL+f5Nx8t/BUmHyHC4ZWrp+337QR6/Oz yoHrf8bFVdBTm9Bp70qtT3uw7YkdpJ1O1sZaXMcTsuhFb80yjFDETofLv7guWHf8SfX/SWi 7JtWqYDaB0F5EaXcZI7HYZKjKpI+VowaUgzdonJn2Ui6S8CD1Y+WjW+Wxq+qIFFqG2qZxFj DXk2Na2Jtl9aRnJx8qqpg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:riv8b/vecL0=:+5F8OSMdE+Zx+eykCFEhxO sXEloGk35kuwMQ5iC/TYfbSAB9sznLnwNrJXrWj7Jk5OzpKPT8u0ngy1jeraukSYsbRn0MMWK knR/CwJOpAFdJ2jBM7/cPpQoJZ9FE0LVEt4nDrJtlj//JFJmEhycdtBa966T40yleoVKHS0gL WgsAnqopPgNtPuRUjMSSgizIw+/EvEa9NAbNL/8trmoyMkvAq1CuclnjBcezPPwXSdUwu+NHP Sl3OWXCGrpLo0M0XOh7qnPS71vZO+yv0H+fo7tb69naKhHJkJKrbfqbYJ9oc+n4K/qyZbvcE7 237XU3QGoEQpSZmZsrZ4EiKudYtVipeMWxioOXuJr79Yvj249PXkrguIB0ixqifO1ibZRmdep SCjTdh5p0KtkMzpk8Lir2TjUSDKfT9CkU7vHDFOD9em1mhiDSpZb1AES9bCzYxoQKBrFgZo4/ jsPLa+68w1XWS7kA1wOQZPAL61WrExikywTtsIH/g8WgBPG8Ruf8LMzWAmIO0WkYGANY4RXou qVOpwgkMRk2ICN4YXEQfRtUSh6JzB1x5rvU7aCGqnAynLrXepMcoaNqY2CyFh1RMy44xlG0of MJ5REbfwjWCRJuMnRTRk+j07qpGttYFTFRIxoM1SXZWyjgbVLS2iCLgHLglHC/EYjgTwARfHw H6wm/l1zWg4hJAB8GsG7Wk1LtL6KpAwJTkICE6JP9XOFRLELnHx3ivbuLW/rJmioKskrTGg1G EVWZfk7TxgGxu+B9CQ7s6gKbol+raNHwF6PBaPNM4HJ7YmAENLbZ0msg1x1DwtHrac69rYXsm Xn52pa6o2p14CdsOaj4VasNPaKIq/glJOv4vosws5YLCcACgZLVwOOxnXomzDp00KqQXxlRH0 nsPGvv9AxjwGIPgElCtA== 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. Acked-by: Max Filippov Signed-off-by: Arnd Bergmann --- arch/xtensa/platforms/iss/include/platform/simcall.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 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 Dec 13 20:52:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181584 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1143285ile; Fri, 13 Dec 2019 12:53:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxIprQEwPHErKYye/Z+u2XJrEpMEWhK0YMWouU7sm2PRBPM8xPP96DtZCYzQipj2ZX4B8dc X-Received: by 2002:a05:6830:1459:: with SMTP id w25mr15882291otp.270.1576270386785; Fri, 13 Dec 2019 12:53:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270386; cv=none; d=google.com; s=arc-20160816; b=WHijEXBgNJ8c5wKPT9MEl8DzOzZNugJQ/G+qoAtsYqIQnVdc9Hs9bBD1tTFs4PCu54 eNvDlPJqUhD3+lkdRp3LTL7F1vwpwQ8JPIU50YgIBHaVDcRZE/hEyG5Yl5kSeWX02SVn HPUliy3UHXrPpsOI30mkYCLwPfHxKDsk4rDSxPA/gOB/+CXz5UgWoTo6IMZQemdx6tqy LS7jN8ev2uRFrBYvseOE0QMPTJDbYACRL1So2B7DlHV3n3DE7Niwa0iHjrCcgQGhBmTK QeCENYeNNb+ZMQA2JPw9k8DsUspNJtRAqLcb/flRZ+/+yETZoHTusrnzq38vDYEr+Nia hfsg== 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=mlNrV/v1GX2//WKai5xnVApWD+ah/4b6I/9j4UmZmJ23k1EoCKkXYwi3oEl1qQvioi ncOAe7VeugPasNwm63WR01P25QvPpsTO9FuLYekYzBbkPf16VKfJeQ5N+2H94KA1h9ld bv5wH8KPUOOueauDER5blocVQYwwdqq/GaphXWkkmvOJarGQLOV/08KP7yrPDXKXwJ4s IcUZweg2LMGNmQFiIJuFUSkHveJ2WqdmEBJWkaLP3iATjctu5r7Q67/h+6PJV8xW1Q3V SIcIZNMsymEORUaMZ8aiBnkRw4fsj0QInUvZCztzdhIWSVJahyh49MrL539Y2r4AHxBA wRCg== 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 i8si5796797otp.254.2019.12.13.12.53.06; Fri, 13 Dec 2019 12:53:06 -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 S1726678AbfLMUxF (ORCPT + 27 others); Fri, 13 Dec 2019 15:53:05 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:45503 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUxE (ORCPT ); Fri, 13 Dec 2019 15:53:04 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MSqbe-1iI6wz0KPG-00UKf7; Fri, 13 Dec 2019 21:52:47 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Jeff Dike , Richard Weinberger , Anton Ivanov Cc: Arnd Bergmann , Alex Dewar , Jens Axboe , linux-um@lists.infradead.org Subject: [PATCH v2 05/24] um: ubd: use 64-bit time_t where possible Date: Fri, 13 Dec 2019 21:52:10 +0100 Message-Id: <20191213205221.3787308-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:mLyO11lzsTki85ngmdRuvZQpffJE2UOI4zLl+uc1b6gL7mCwrB9 c4BgVt5uCUzPtnrvPR47NFtCTQDbqK683AKz1oOVgkq1Ekn5QNnTb1ut06woz/k2ZQC0VGj oK9OwugHAi5tHUSZe5Suajf52pVQAEIFogivdYkNfobGxUDXRSqRAqJMt6v1s4DxoODHhav NLcxeYqWv0+1bUYscHkYw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:lpUtqwLVCdA=:kSwfzyihbAiqRgvELZEZgw ofiAbMScdf0/jQ3hSJSbhdbyxxp+89hmduPl29UJkD3j5yjZIA2oA3utstDuUPtm30kcNJ2NI AEpPoyKYgCNnf97kHPdp1Uf/8oQaNKSuL2GSU7i1kanybJcWX92AmB7WnD8qEDsFhNMa+qvNh 34zxoGTz9YXc71+JnkFdEzavB8jJ71oGjZQEyIqmVJul7tkc2xaHpvdaYzvZJtqizzuYywi9b pmARFGfViQU2mhSrJBpKFBrCKLb0wWNmF0m5aRNkRDJwVd/3z0KNMOf0BI1jwHOgRzSEdQVco ADciMXWq4KfrjGF0EEwGeCtpqnzNQDgvUFTcPeCidp9+0adoL4ix/8b93qp9QHTvWWAhA4/FA 6JvEn8s91+CGmsJHeiaYENY0Jv8agE7mfyl3oBL5Mb58IBlisMXxcuC+9rg4n5p748+CJeOGz qTtkI6v8tx4SYiqCYJj8XUaj8ngKL+61rXJ179AupfW54rlYDICkwor5FIlIPNlAkuLI08Zyi hH3QuzvF6ZnbyifOy8xqY7TowWpvLvkO9Kf0VpmcUQiaSqBfasmMKGqZx/aqTRu8wPdqfGtxp jdhCKQzx1dqD+Y2etSM1KPr1abmF+GoPrusLcbicfouDBPZ/ixNoXiz1OgyI/+YcTVoTSk9za 0Az7W/wQ5bG+RSNvuyrwEEmmxrnCMXsC0gQ1MKUz7BonL1WklSo8HDdkDymkbhnNY/hsSij1f AmTRuwuSKiFQreqJXHEUlB8/vhXxvRMQd1j0oU3MZWbX8iTx/wFv4KtanhxyeN15RwYaoon6c qBciYRn8Rg9RNO8tUTbLHNCvyJhk+73r5JopIHEvYsY5Pk8ZyaEeVloh7InU3IvkdRVd3deDg cjYxvXEdMto71IAA8WdQ== 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 Dec 13 20:52:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181585 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1143536ile; Fri, 13 Dec 2019 12:53:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxZj624p5QwDiPug1bUklf2d3sM1dD2OgOor4Nxn7u6hDmKiE7UjAt2rstGLc2qfENVeKQJ X-Received: by 2002:a9d:7592:: with SMTP id s18mr17410315otk.130.1576270400704; Fri, 13 Dec 2019 12:53:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270400; cv=none; d=google.com; s=arc-20160816; b=eZOmpLIdgkp2nN/t/gnFWKaXx+EyZIergk3j0vJ86CNKwR7bJM0iO8uivTEtieYCw7 haArVtuzWT26a6K4PbU5l9kk4vTZindR7OmUJTwIxwR7gbsQnwCchXNXxM8KjGFt6JQR WQTWsE058N/EV3ZO300M3Ic610+nJDp+yyStvWa7hA9J0tyb0wZrAubi6LYnzVS32LNR 4WIYKsGWMfTs4cJW4x5BkS0CBg9WW9rhO061jeWDxAv4zUR6WjcrFAeeNHP6TuqDucHw 4yXowi0O+KOSREq01R/VHPYCZKRDiSWkw6PMacgPNcUw9hCK0qrn2oqRm44G5H7F0Axa exqQ== 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=rBML6CP5efbAwpBOEcSqEKRH1WN2QxRhHfmU+YUWMxtcET6oDTJYl7X6HABzc6My/M FCnlHvKnCVRut3zgVbjyqGYI5o3UPNRRe6JyGHi8+zWcHw6SkXhGGVvG4JIgS8tu6AYk MBrtumS2FuLMyQ/+jbDr/Z4nJKvX3NZhcJOrVj8BCHLPsfzh/j0/jLZ7Bbm25xYgmWa0 NrpR+o5i4sDjHKCKDTJUIzTi3Mlst0y3R7p6aZEa3ebahZkHuRwOH9qAX+u7FEzE4dE9 PbM9aceLWROzcmip76pxGSF3f2Nh3BIleN+zzvyHShStNTPZDdW+9R7t5tAXMLdIrpEo oUdQ== 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 q124si5349494oig.228.2019.12.13.12.53.20; Fri, 13 Dec 2019 12:53:20 -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 S1726802AbfLMUxT (ORCPT + 27 others); Fri, 13 Dec 2019 15:53:19 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:46181 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726671AbfLMUxQ (ORCPT ); Fri, 13 Dec 2019 15:53:16 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MeDYt-1i6oQm1xF1-00bIho; Fri, 13 Dec 2019 21:53:07 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Al Viro , Richard Fontana , Thomas Gleixner Subject: [PATCH v2 06/24] acct: stop using get_seconds() Date: Fri, 13 Dec 2019 21:52:11 +0100 Message-Id: <20191213205221.3787308-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:st6X4iFmtJPxqaDEnWHJh5aO982P37Ptwn8bOhTHFWKcELag9Vj u9uy/F7aNCOxmXM8GDWXhPfPSVohIQLF/cpqmdRNDJlyjs5FoLkKZXuOl1wSWlYQ+1kjRh1 MXR+HAXY+hf6qeZTKw5iO08MRRwWmloaOTspzIIzU3UYsnTgVrHP72aqgmTNlwyM7j30jQ2 ewbhl+TxIIDPyaymGx+bQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:/P5Nke/yFgs=:XJpZhgz8TDetTezFII4o2+ eXtRcfcirHDAi9Zi9JHrQDJaNR+fsE6lgyR707lukk/IkDM5bdUiibJAQ8wFN2sk1x185EgE5 aCcIicl9JjgSh/3cxoeTedHnNmfg1HeleLIzCjxIYdYjLvquUQ0glGyP5LwcXSoExbYO6mVFE k5kXjzj8TxswNKV/NprsXkAmOdvMes1Rgz3pO19JRyXoMNqziMbjrT341AOaPEXbSC6gUGf8p abvoniCwWC0GkuJYSjw2qu97X5on4kRIS5wWU0dL6v9u9eg+tZWj5NVZz5prgYthgfvZ1yMjH Qe298ynwsh/zQY702mgpyvtXeNkSWK3fE6Fm5xoSfSYpDL2Tm86jGicej116D5fLtske8/c2N qThlrJvEkG/VomPdkDfKgJB7SE9E18ESIoOhHB8chd0fkzMSCF3jTzC4/OKRvC3kLQTp6xkuy p+F3k62RNvB9ErWZq4Ul8Cu3fgdqnoxHT6J9uGyYilnUH8HCDjxYVfz9j2O212z6ouv1yzqIq iT1G4fOMAVL4Pf2abMV4314Xdj/8ZCqa+wNa2okbhe9kfPM2TG3Nd9agKIBIF5IDGQgeJSbH0 bf3F/RlQJ9IGAfWsNOt3X1fbZjlPQqnz7WL3pHPfZgEyCNq6bAEMKQlpJUovkamad/tr3BC+D DsQTqla5WW7KA1bmzTQ7nYz2YWitL+QoR9Ws1azKdiaa0vl4DEVUbXGEMoCDOkMP4VyzzSbYP wLYnd/v1HIBAAgmrdLwXsj9HYxHN6PaZSaC0NXOI1y9HrOUJTCNKeDSOy1MXmBb3HzdrvBIbW BSRYylPiHr0k8ZgJbYFXWRqFac/9Cl0riOhWctfDhLU8LLgOIgGzpCem/gwaLXqQOKHzi5wXc EIJXG1qqpjICfJ6VXKwA== 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 Dec 13 20:52:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181586 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1143730ile; Fri, 13 Dec 2019 12:53:34 -0800 (PST) X-Google-Smtp-Source: APXvYqw799uCpBEQWwhtt7yBM5nI/lySxpy2VGtNj58yZbTZgCFNSYzln3PKKr/4Wf65P2LIJ9gL X-Received: by 2002:a05:6830:128e:: with SMTP id z14mr16155995otp.184.1576270414394; Fri, 13 Dec 2019 12:53:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270414; cv=none; d=google.com; s=arc-20160816; b=h8glfTPpPbVU8jxBNWeiHvpTtttZCl7tg4R2Dsyv7NLN2Pv14CtGjGCVBoZaEw6i+t QudWx8vFpWQwcR5QxJQOtZ41/ws8hj+9BmuSbTazxQ7uCXKjhDTXijKS47pmGN+9Mccm +wtrLUJZF9wvY4Mpdrp9WKfe2j4ypSI0Cr3CHJgqElGqYi6CKiyu1PhDmaBbkzIE0+w/ aZYRYwdZ1w+xeZUZvvOIJA7obeDrNPh29buAMUOya3+nv9mY/ounrG2oyG3dU+xsc/1X KIATl3dOeleYTlzDYKeN4eYctzmuP4phKAJRQ5lqPzqEJ1QQP0/VMuCycW9KmriA6L35 xJLA== 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=h6CMObD2lxVurx+Cn63BoVF75bpRAjtNwYmuVIaQwhhjKOFas1NVLlSxhUVdZNEoTa jClUfVsLErPZc6nIAU1pGLhv3tqU1E9EvV/CRpg2yh6qdPKKkKaskz2P2mxaXHwtqJeB sjM5Q7kJYZ6/KsDLAXnTy/lnCAhe8Iv0Nnk4EA3kT4Pwm/rnD14mCspg3WnFgwYJ9ONf 637VJjmZ2ILyYjy1uc4mjvIuF6/NYLvvc8bX3NdwU6FrwIc1aLM1/OcXMYwRfOw9QgUd CpkY2xzz7g3njdpD2+ucjcNn35V8DuFDKkTnbrNYsd3ei7BzQDujTyw0WKV12X25OaKN kO7Q== 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 q124si5349494oig.228.2019.12.13.12.53.33; Fri, 13 Dec 2019 12:53:34 -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 S1726813AbfLMUxd (ORCPT + 27 others); Fri, 13 Dec 2019 15:53:33 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:55983 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbfLMUxc (ORCPT ); Fri, 13 Dec 2019 15:53:32 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MNwXA-1iLyXr40AC-00OKO3; Fri, 13 Dec 2019 21:53:24 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Thomas Gleixner , Richard Fontana Subject: [PATCH v2 07/24] tsacct: add 64-bit btime field Date: Fri, 13 Dec 2019 21:52:12 +0100 Message-Id: <20191213205221.3787308-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:m6zEFmAIGteUTAMEdgs5prJfD/t974ZJHKfzjd8SuVlLVyFh89i pvk7yilTWbmNQeMsJ/AlHqqLtide7TxY7hZG6X9HBcpWwfIX0yPr/Drv3EvsHl7n+Ml6j1d 0tOFRa0UPRlTwNTtR5mokYRAhW18Uz1TBCButDDeBDX9U8H7nv//rgGg3Nym7/5yfm1OSLO m6dEvLkEgCjTO+uvaQQuw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:wVYUFpoDrxs=:RY9/vsc3D1VxscEnAiUjml r0KGyz2oGh43qf6yyRErfNzcXG7W5xEASsxVzHdgjutQQj0BXyWsru5UoBMgVsN2syAWj46kC LsGnxVyODBZoFq5D78OZmppOUNowPq2YnUB9NsuGeAKwyFqsyp7ruvHJl8GrnV82dC7o1DAJK csMhiVhkyRpeHfYWvTpdpsqMjiAnJ4G0iW2O76y/rST1OmxNaQErWizbTTsWnAPQ+rCDUNFYc zwcUFx3zSylWCIy0UztN1cozDHepsL1MltTnJIb/QSOdXHGm69gbReBhRbnVhMG528q2PeQ2E VVOzhkk7c1tKILcnfKYfjAXd/em5NjgdKrs2Tbq30EBdAl6G4uSJ/NrrAPmQXIMQ7I/pKdrJj VaUTzaCMZcUF5Xx6AGKfp1aafz891WMvLD5KSUWWq5BnSjYIuvAtxSm5/DzrKXBmQSyyHTGyX b7IKA+z2tSj619vxwcEZ9Z102Qak/ufaiqu4y/3pi1eyLLMW7nQuJX5VQB3GzpYccO3NJDup8 i45sVCFKrftpu4Xb5shNAcgsZB9Ne2VUOic3nmJmea9A7NQsCoPg4kRW/7dMO/SKZkhsbXH/v kwEtCz27McMrJsoswg4BWMZml6pWFE2v53bTVbdc3Kfx6EpuEHndvFJ3ClXKXOsPSXrLsA6HF 3Zpb25Cs571FdJfN2WBbajDvC/F3X58/54uE+4+EaEtQ5ve+CHOeyedjRyZ0H8znillRbOn80 gUKaHvzdCS3hZ6kLNcdGaNX88Auct2TyW8oT+DMyw+BQPe+J4f7aThFCMMukmc01+KNPUoLTq OhMDWmoWzoAoMdlvSPaD/HakQGGxTfttI7bG4VDtDOlBiGp5CBEvlbFtpm0A5xuNwtaLs58uJ jVlHaEdEr1biLGL6AN6w== 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 Dec 13 20:52:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181588 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1144027ile; Fri, 13 Dec 2019 12:53:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwPIdVD16x8hAsnISYUSA2ghi4dewzoAv4MmsrHXWnOcQEAQcp6nYKROvXLkKHRuslhMATW X-Received: by 2002:a05:6830:12d0:: with SMTP id a16mr17129937otq.8.1576270434926; Fri, 13 Dec 2019 12:53:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270434; cv=none; d=google.com; s=arc-20160816; b=jYL9oKi0g1dm+5vo2FensEMywzg5zOwWjtcNLZ33YTAsh+fOwVKlOqcN0edpJps+Me FjBkmMx+qyvBwdCW23NG3JcyP/9lNfGV9H4IHjRRGQxDmRmfTc6bb33hgDMh6m9XLbyD ihqGqWYln6EiEOvJihig6S8a+fyrrtKwmwGcizBOWBL6wWUyuaOslvgX+LnPAbwn8HOb eJoEf5Z5T7IuzlA/GaB30zpBoFXEFJaKyZw31Wxc7Evbp3Nf0oQyUIBh27zGQser5l8w rK2OoeNZPgC3Isjc3jikEKBpWa5yp3Leow8pVdzm5Sq8Be5iv2DgGql9n5DUTtOWaKhC 46Xg== 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=HTofxynQLlljq8mnr7C986Z2bdHYybP8om/JFUwpjMk=; b=aU3k7blcX8x2eQYmFRaQqao8CoWXDYCPUF6FYJfKNiSNxprZFWuA+J4fMrtDwZJuyS zp34+R1Lu02WIkXdwjkrbRypNHck5a036s1DhBks391NHSFffBf4Bi88e1x6LQO9zij0 jpJST2VWahAAPkPJwMN/T3gtn3JMfdPKmjtGX/wP0SxmXua2INYQ1AgrpXJZGWL3COUE GbHOb7McIg4ouZvBkJkeZ2BMBNy4pPA332gCWZM2pbQN5UP7SrovHLCMjTmuY0m9ZjOa vESiTH70hiA8QrbmlpraDEJgVU6yoqEQw11SDz4jXAX07/3040oCothNy+nkx0iVpBfo obaw== 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 a22si4510797otr.143.2019.12.13.12.53.54; Fri, 13 Dec 2019 12:53:54 -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 S1726840AbfLMUxu (ORCPT + 27 others); Fri, 13 Dec 2019 15:53:50 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:43261 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfLMUxt (ORCPT ); Fri, 13 Dec 2019 15:53:49 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mf3yk-1i3ky22RkQ-00gY1h; Fri, 13 Dec 2019 21:53:36 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "David S. Miller" Cc: Arnd Bergmann , Willem de Bruijn , Eric Dumazet , Maxim Mikityanskiy , Paolo Abeni , netdev@vger.kernel.org Subject: [PATCH v2 08/24] packet: clarify timestamp overflow Date: Fri, 13 Dec 2019 21:52:13 +0100 Message-Id: <20191213205221.3787308-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:kKBta+G+as32YcXvSh8tqOxFF8jEv1GeP9pum+Ut03Clje4yb0Y szlos7jj5U38a9OyuzukApS8mGz2pEGMpu1kdmhnUtVYGq1KoMKrBMvwG2Ju1qHHmp6TxBX Ckl2dSzUfranvLS9EdhP4rZF83JADlDdY8rQeETo2twFKq2U+Hc5gvv4bWLL/UDNPmm4X9p JVMHJaWzJlbVlDbLw7GIQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:IRdm5OTc3rE=:EZmf5cbRyzKAHD8CnHoxmH gRxlyJt2cIfonuW1EgiTb6S6CC3kH7g5rzAgTaMgZ0k1RpIInOJ2F8y2+gd9A6VUVkKi5JCGb kd3iCHr+Obp8BOvM4r1mNwxlrC+n9BXx0w+2KXY6qh2qXG4lNnP1LNV+ftLNGZtPFNdGOrKcr wsh4atIZsxCGAek99Bp7zpXILcoh8saZ3vcIf+IuU9ytJDcsTP02o2wd4tQPS8FuXsZG/EYpG gP6AS9n28Y9Q5BEtZXdAAM6SeL4CGa+8eL10mRk9ruYXac+Uyk50eNmdioIsalwVYhAQPqN8g sD5ZAbLLfyKD01KehEeUvUEtOJMNUdtUaaDUGmvQx6LkICIZjvEKGY7tfG3W4jxBJ5+fRR3It 8D81cJPCLAx8nBmUVJXvnDtvRYZSI2xaDDdi+v4p7ge5IviGf4LvGxsUqG22NAIuIsEGPwswR MRpgwWx95S8xjpP+eM8f35d4yEg8Zwl8cf0QSE2vRpxNTSN6BAC23Ugpc0MgkaZvTN6PlgHy3 3Yh1MDgPA8QogrIr5jLZby5BU44A12q/x8ulD0APdnweT0jCXUQqUm2wLBb3dbSpdtinVL147 5kntc3jlnYo6w1mCqN9CRLprjxVgRpKRgCR3UEcqVEYjOLu2pY7wTgGZOOfyYAuJotpjSCjr/ XlSIPO8GPwp3rLOl6z/JJoPmio90dX0nZi0jpOFeN9uHM9zbTXcnSGed0EnppfrcBJMoVR+YR 3ZyCOZjrtvRn5uKUkBZwnN1TgWzSHQpGViJqM8zRLcUpooFBFjgaWbyMEEB0HDT06PmgwsZKV ybKqE9JyyG90ElcZMYr1x0qseCj9ADA+RrT2+g9cu3G0ogv7a92+boY1NSUaS8oRVuYX9JbMU 1ytJBPm9j09YOD61HG6Q== 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 53c1d41fb1c9..60300f3fcddc 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; @@ -2168,7 +2175,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; @@ -2300,7 +2307,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 Dec 13 20:52:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181587 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1143991ile; Fri, 13 Dec 2019 12:53:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwtUjcay5iJbD0QXoHJQ9A8rOfb4pPUHRsh1o1ugUnVJ/e4PZ/hBAY8cxa1NhivKX2USbNl X-Received: by 2002:aca:2419:: with SMTP id n25mr7983817oic.13.1576270431906; Fri, 13 Dec 2019 12:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270431; cv=none; d=google.com; s=arc-20160816; b=RVv2PWCSrduPZK7t/ayzfocsqTZ8uPcQXo9i6/VV41bYloyUmF4IksvF5gpGyUCTaE ZK846UgYVriwLS3RV3bpP92QdXCrWPgrd+lzx23cZRi+csXVk6MXUQjFiixz1AKftA/1 UjHKpxsC0eMB9xMeEvexitaFf8e1tMYBVym+24x4oYhHD5z+QjFmf9nWQc/bNlIRitFb I6Lm6T1D9MwOG6nQ7Ph4iEDdKPj4aptuLglRFHqZfgPLLONUG7aG9n8S04gMjOO/bvyG QlCziZsM8j0wZ7BIVg+LB09QJXWTB4BpSIWwY8pc4OFmdLO/ppCXRZxmpPoYp+ktyX4T 65xQ== 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=O46q9WaYRWlO/XCNCZqH4ed8y3p6ylT89CVasCBQfn4GwERV12tbjjjOd6fZFIm+Ca HjLlV4FCRn1dHg5r9WCX/F15FwReO1DRnFIQ/Fk07gOhKHGUkcYKV0c5anezBRYqUfEZ AF0FBoSI4XKWU281Pkk42eQJnwpq3nyHOW1pc35O5aHQNH3URn6Y695Gh8QauN/h5pZz dWTPExip6g9r55qOV2YAzcdQLFddJ+y5/5EFecD/+fyN9Aj4GcDODyi7Nxl4T0uNH02m RJDITkp5/Gt6GvNUT6n50N9sfivw9ohjFMDk7Q75ls0oBrdrEIYWDpkzJw+otaSr7LPf bzcA== 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 q124si5349494oig.228.2019.12.13.12.53.51; Fri, 13 Dec 2019 12:53:51 -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 S1726861AbfLMUxu (ORCPT + 27 others); Fri, 13 Dec 2019 15:53:50 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:43623 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726368AbfLMUxu (ORCPT ); Fri, 13 Dec 2019 15:53:50 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MtPzy-1hrbs61fsU-00uu3R; Fri, 13 Dec 2019 21:53:44 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Jan Kara Cc: Arnd Bergmann Subject: [PATCH v2 09/24] quota: avoid time_t in v1_disk_dqblk definition Date: Fri, 13 Dec 2019 21:52:14 +0100 Message-Id: <20191213205221.3787308-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:JA7cpk/zrzgly8p4eMkgobmlMJH0BMfBiwOJE0Fs7DHb5ktCnCi 4ESYtf31/8tN6P0cPzC0yFn0laxJc/QFQXw5yqhqeqf3hw+o2aPYCSrC4uyq80+26JiYCSk f9UCvx2M1LKkwJ0iBS7og9top0ULb6NFXd4WfS6ObMnEuC8Cqstc2AzAtAYJEyVJG72cw0a nk/+WMbJdV84YlXKRlXTQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DY+jB6jkCoE=:LPR123PfwdTfbPBsMalpyh XsMoebsMEG+HS54UZhHzOguZ4kpUBUtJVW/uhMldV9SSQXHLyMyAwrFB23cEB62cU+g0PgZU1 yapEPpJfZbWtRzGP4uoB2dz6fdQf/hKB4Sp26WQ7pURg3j8VmUBMZfzbQ7FbImq2iwjMttdnx J0HUvbCf209VXVwRQdc1gtlTh7PA4GEfwPBXtKL84dvdxMHibA+hHIlTXk5NLKhI/ilPV6+rk KxPxW3UNxXKiimGzrnJluGgckq4j066VjdBFz4kxhA8AHcfi+ohvELwI/dH+tpHNID3/8TyGM vQQMlOOdzYsP0vXX2+P2CsysMO/wbFozYDN9M5MDmw6801gisn7euKl4g/tphNdTnHn4DO9El ac2+E/4WlNnt0N0t6kyF9Xh3T0aACkbzuMk3+mRReT/x2lAWs+3qeIuY1me0NH1V05wvX5377 ax2JoShYAdF2XbMMGdswrfoGcvXqSImhNds79AEjAALgvIGtRZwThwFdoCb1hNVvM1CKxmeO5 moZrMHZoYAEfcus7YSYUHSuVgy6V16trfaV7T7ZGKhRV04QFpa1Sin2SvnG95AMhnBioTV5kS CSnpuerWLyEo/T2nyhowzzvZ5D41g4PUSf1JlC1mCYtMp+bCJetXIRJKoiqELcA5K0wdZSD2H UIwb75m/MiplnjAn5/izcCtucP5xpSrOAvEq7bO9JKm6pHd3gwxmd22JNOVTS7dl1SeAE3E99 Uq/qmtkiz19j/nLnE3egxx9+W5ePQTWxJv5I/YGYIPBmT3tXt0/pCDO1qALjUwLh1S7mWODvL I/gRizkAwzzjscnH4KO48JzNtFfSHsN1HN/t10WpGV2MjHVzect+1gQ6I9e+KGhjTxO93FNkZ WqwSNDnrg0Ee0trcW40w== 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 Dec 13 20:53:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181589 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1144579ile; Fri, 13 Dec 2019 12:54:34 -0800 (PST) X-Google-Smtp-Source: APXvYqwqFE/cTR+d7GJxzEVtfkfWM07dyiPlfu8syTjgOjll++/DnVZ2e2RMDUC3j2HcBAWyCGWY X-Received: by 2002:a05:6830:1c8a:: with SMTP id v10mr15808101otf.115.1576270474303; Fri, 13 Dec 2019 12:54:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270474; cv=none; d=google.com; s=arc-20160816; b=iYJEfnVEAW9hMpQj1dMxoVBtV+aK6sUoYax9S+Eq1CsU5XH3ikZnViU5Dy9PcDXreT lIMFmJAWbFoGhXK9yPZ0OIDXRPNNMt8qMUfLr0Kh651qSLp1uTXY3Qa+qsBysAbjm+jL Dbz844OxvtJ2AxAGzSAr96Z0C8Bmu8IHvkm7ukP3QmMrZRkJhM7AFMn2Li5N8OJwyCZV T2o9noZopQn/AmWHKHa+bFK9CLLGVassySz5JzS7nCgQr78LpSw+UbJCrNEW8x39Qbhk fIS1BYduLnbekx+UFduqDKFhUDmhnOnadTVyVKwPewPhPirI9Mc2fVquxLDPQwZbEO2Z h7ig== 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=W3Hw7C+GbDzcsKy17Wx270v/Cs7+z2pZMkKPLtAC3bxvyE4OQvN1zKFHT3wVCjL+Yj 6qDPS4VvCqm7n+C1kCpWLuGQGXRWvIGEMnFXKBKZHZOu5AH71qmbbEFtLjWH4MgINWV5 qoqlEp00NvUIeSyboEO5lwKCMnuM+RECkrWH4z6dlDFLP+DCFLNv/RBoIMurk+GiMnl+ eHvw8Sbede4xni5O6+pSlsoMK0p07jkTjDcsWnTgd7KwnNzmVIcxCmfe6rhF/1mkre5c Pp8WayPruA5DK3pDRn3PABzvfpdN4GEJF6czpSOJlaoMD76/YSqrvifxlgZoaSO49MX2 Tlww== 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 w187si5489066oia.166.2019.12.13.12.54.34; Fri, 13 Dec 2019 12:54:34 -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 S1726863AbfLMUyd (ORCPT + 27 others); Fri, 13 Dec 2019 15:54:33 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:42315 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUyc (ORCPT ); Fri, 13 Dec 2019 15:54:32 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MgNQd-1i4aSD2T9D-00huUn; Fri, 13 Dec 2019 21:54:18 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Jeff Dike , Richard Weinberger , Anton Ivanov Cc: Arnd Bergmann , linux-um@lists.infradead.org Subject: [PATCH v2 10/24] hostfs: pass 64-bit timestamps to/from user space Date: Fri, 13 Dec 2019 21:53:38 +0100 Message-Id: <20191213205417.3871055-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:a6AdbmdDziwYGHu+FLwRLl9xFjl6ntLHucVI0g7wMYChjz0a15h smNUqa7abfPVyLZDEicFzc+kxaoNSdsVsBhb2C3KoKHnF4X8drVpnzEeQwBcbSTwVrbA4ZE l/jIyoAGeOSrx0BHpxPkM9AhZOahh3h/KMQdhAQJBgsQmtKP1NyFUKIJaAQ9SbK3m9M929y ljS3RSrIpKC/5sFEyqAAQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:b1QJuSoZs2Y=:1GUnlu2dF2dprRPCt31Clf Kv1y3O8o9ERlAkl4V0Fe0QrmFl1eJGcoNbAP0shJliOwxb439vJP2ESzT6Q6LmTMB/1OUgg9L E8Eo8/uwZZx5ox+EFguRWTmeEqyers2S/DSkAwyHIIrMAzFr8MyXCyhm009u6VdNeqCkCZFk4 e1QPQn3EmkzHcdqZUu7o5eZFrT7OWWdmJQrWh68tRPsSPlHGqTn19fa4eHLmlpExQ8JxzgArD t8eCWD9AwqyNgGiMB7tiqzu5ddMtDEFtWuXgss4ODnuNNPpz2g8dUGsqKO1W5yFO+B8zffSMs iTkexflWc1Ypsz4//U87m4Xu3OVdSBxRG1m+/lYHw1KEoDAUwJfg5+k256HLY6TjdHxZCABIL GI64J+yahQXalgJZAXy5iwZA8cLeJWtJC8ByybbPqW8PUjSD76HnNYIHjBufaflMJ0guhkC+4 sYwivnoImJE9ADg5/9YBzIESX7pRf/SUfjiLs9A15TqtB4NlVfNeFDoRZbBpFScRWO+4PbQbD FqLeH63FvQfoifJVe4Qfae2M9f6G0FKaqVFof3e5uDC3Zyv1KgHQN0YLphROlOsL7ZRuoNaE6 DQDZGX8LVOCgHnoleFFuqaASFjkLl69bGmbUCy+2H1d8KVZa9J/AMKydajYxybqMjHt1Ac6CS SZtUewPJGvklOSadqpjRJquJhKDiz9Vmq6zZRh13oCELpbJlrQTDjJmO0dRcdr1YKe+j/gM2d gWZN+GMeXDsvdTyYfsux7MOfX/hcSZ9O8F95amXeLAxhJJR322Q3FWab15NoFKliM0HGKZEzb vYWwoCO7nFofkOIokJhiMcWeRAvAGdQYpyCKuveyQ8wLV4bDaHIIIEvxvEVnG0HowsDZgTSO5 LWDJ78F7la/VYdUw7G1w== 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 Dec 13 20:53:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181590 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1144646ile; Fri, 13 Dec 2019 12:54:39 -0800 (PST) X-Google-Smtp-Source: APXvYqwoRHKDBW1smsr099asfAsBo79Urt2497gOWRF/dZlv1DRlXBOzspZDMqe9e8xYBnhErS+c X-Received: by 2002:a05:6830:13d3:: with SMTP id e19mr16768602otq.135.1576270479321; Fri, 13 Dec 2019 12:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270479; cv=none; d=google.com; s=arc-20160816; b=HJJW+vquj2US8Uq/CqIyIuYRWtCxLLDtfsE+o8ZU9AOFSrljPfjHtKY6ebF9v3J12a pMJtJ7GyugBppkyH6hTqFZP31STqKLUshyu8Iv+uOxH/g3n4su/5JJpO8ZNA//cb+pgb TflJwi0HrucwUYbQX6njV0teevKvosvZH/dXubcOt4EY2aL45waKv4qhjBrlQ3t9aVVB sh2DhwgBNvA/OpImKH6Jay7W2hZaxJqkkx1WFKxN300ecarpTgRPNrKEobNoE6Y/+yyy yC9NPvLyA5jhYmnZ9Ja6ZidKeoq7KdhIFiIG1YjqBKAdZ4VN2FVeDKC602zQfMBFh+CM Ln9Q== 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=0yTsspsJvG47l3vCLtgqRivDERFS4xxtMW0zutIpZxI=; b=n8u1rYMUEYJWdx8f2oEnhN7+UMtsVm9U0sg/tky32FSRlNSypgb5LXNGgDd+K0QQTT PVA4FhcLVNU/9J5d+YkYFEYA2NxdznJZLquucTwZDoFAiepSXIJDA5F4RWS88t+3y7Is KMS3mfql1ogwbLzbV8oOgKzTnZIMmLqKE9ODXtoyyyba8Hlrnm+lmyhOMNpCTJ+GU7Qq t4QJaqxintIhcOnFpiVIHQk+zpcA3zp0R5WqMGAzuqDc4O6ikPD3dyABEqo9/0HXFIRx xWo/Z0q4M5TqVJ+5jts2pfKywMeRUNoMnSj4V4iEQ92U4PkPerkLzvXzNuJ7qlG9Scov CxdQ== 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 b79si5575279oii.162.2019.12.13.12.54.38; Fri, 13 Dec 2019 12:54: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 S1726880AbfLMUyh (ORCPT + 27 others); Fri, 13 Dec 2019 15:54:37 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:45667 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUyh (ORCPT ); Fri, 13 Dec 2019 15:54:37 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M27Bp-1ihmpU2pLt-002XGN; Fri, 13 Dec 2019 21:54:33 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann , =?utf-8?q?Ernesto_A=2E_Fern=C3=A1ndez?= , Vyacheslav Dubeyko , Andrew Morton , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 11/24] hfs/hfsplus: use 64-bit inode timestamps Date: Fri, 13 Dec 2019 21:53:39 +0100 Message-Id: <20191213205417.3871055-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:XqMpj8o6u9NYzuj3rgf12in7GXdK8b+g+ASj7vaIy/neEOyN42J 4kT//QrdC+R3EDPxtHVZ/GkJhWttxJWqahEX0zv64cj5oVuoYETGHG7oAHIYvpX2QosSvct ddBHO8D9+gADwoHY/gMwsp+K8ZyU+RCb5H3wQhtrjjk1NJBofRa8YMkMBg5jQdZsGihO7o+ PHBn9nB5gcuj9pJPu9ANQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:lQyG22QQ74k=:ppxLRXs2HfG+wch52J7SEk D7vKzuAX84XA4nvpIl9pgCmZ/WszjP/JKenJt8zkWiyaqhv9g7S8o3UtrHQzMDFBy+FvMxkzD 1wQTppPANHKEygSveUEB7C4GyKYJKKyXZrxaaHY2aZxA9/tZ0owbANhc55kdmOET37BB4kah6 krpCRoJYNau0FCEfNb9EMZ6LtUDsXWyW10Rb8/qr2YsO1TqKYHpnnRfE3Gpj6g4TS2iEjvudY uDEaQ+1N/yAsEiwlO/PFXB0zetAbmlY9wJqBvgP+IemkMrQlb1HZ2WBHDfhqQsMEYfezENF9j hc3pOObQTJJvnti1eoNs2+/n/VwjaYkdfN9I06QkJu9BTcPoFrG58Ka4oQtFOUc6Wo323Ri5R yvg6aUqXB6LhXW2WJ4r88lOMb9CwbA2XbkzFaQaSv1xboMfCSLX9Rt9i534Pw0H74mbv+Lxvv pEa7B2vboRbQ+K/m6xDeladD96+1JAFq5cZ1sk9uG+nYoJEgrGswD/+hHAojvDtHPAS67rsUv XijjSC6/OQ7QIHXBeW/eMkTJTq1+bcBIESvd4fAUezzzh6sdk1ophSDRoGikTQPpc1mQMb9MT Ay4/4V8tBUo6zjEJiWIdNi4EGi+sfGLcHjJebbJQbTTHMmmfc3crLXKDeQuk/+G7apM5uT0XV 7XUE3l3cJiIvAuuKeiKg+a+/bf1BtZb/cmkW5xT1GIVcABv1q/4QuAnTBntK0x2XPKo2RPXc/ rP0+BId4mwx7RiH78nufQOhFHQ+HHiCM1cK2QTtN0yQ68mR/saRKx5y66QzBn+SeflQUuJJZY vB7SJHkcCtt7VQgtTCoyaAY+0i5ENre+M8lNhgOGwyl0oTwAUvTIkeWtYF8vIgX+ctKktIqdW PgeweHdDkgOgDmvJtp1g== 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/ Suggested-by: "Ernesto A. Fernández" Reviewed-by: Vyacheslav Dubeyko Reviewed-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 | 28 ++++++++++++++++++++++------ fs/hfs/inode.c | 4 ++-- fs/hfsplus/hfsplus_fs.h | 28 +++++++++++++++++++++++----- fs/hfsplus/inode.c | 12 ++++++------ 4 files changed, 53 insertions(+), 19 deletions(-) -- 2.20.0 diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h index 6d0783e2e276..f71c384064c8 100644 --- a/fs/hfs/hfs_fs.h +++ b/fs/hfs/hfs_fs.h @@ -242,19 +242,35 @@ 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 HFS_UTC_OFFSET (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) +#define HFS_UTC_OFFSET 2082844800U +static inline time64_t __hfs_m_to_utime(__be32 mt) +{ + time64_t ut = (u32)(be32_to_cpu(mt) - HFS_UTC_OFFSET); + + 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) + HFS_UTC_OFFSET); +} #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..3b03fff68543 100644 --- a/fs/hfsplus/hfsplus_fs.h +++ b/fs/hfsplus/hfsplus_fs.h @@ -533,13 +533,31 @@ 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 HFSPLUS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106. + */ +#define HFSPLUS_UTC_OFFSET 2082844800U + +static inline time64_t __hfsp_mt2ut(__be32 mt) +{ + time64_t ut = (u32)(be32_to_cpu(mt) - HFSPLUS_UTC_OFFSET); + + return ut; +} + +static inline __be32 __hfsp_ut2mt(time64_t ut) +{ + return cpu_to_be32(lower_32_bits(ut) + HFSPLUS_UTC_OFFSET); +} /* 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 Dec 13 20:53: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: 181591 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1145137ile; Fri, 13 Dec 2019 12:55:18 -0800 (PST) X-Google-Smtp-Source: APXvYqzyRQP/v+4h9l9sxXbPOO41Bz9fvdCudOfwLxoVYZUIhKz/JWGiAyWAmeY4kUF6IWzMfWMQ X-Received: by 2002:a9d:70cb:: with SMTP id w11mr17094623otj.157.1576270518406; Fri, 13 Dec 2019 12:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270518; cv=none; d=google.com; s=arc-20160816; b=iGSpgpXQbQQnihd3W8aZQX0G6dCI+sAJqT84sS32a92nWfydcpGDnXYbqDwakLXAEz KxIKIzlghAex/HrCN3So9oikECG6hTT8BLfbH/vT3kll1COhSmS7aDOAbCa32JIZfeyg 0S+OoRFIB/z5SFwRuTanXimAn4wk3t6wNs5zjl5CeVbxnpxMUdpnpwiyGEc58IdmS5BF aIPfBTqpQ+ccf9yR+kM2q7ZbpjF1RscjLzsVf3c6J0Wv4gFLlyZvuuAg0w9ybX/iWcJn PHM1DFWZSSmbfJJO+oZj5gTGAe6IsS2wum718pKsQw7Huhjd+3m7LGBkxzY7sY1vDsrC VPzg== 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=ShaZAF4+x8CFNZ7oHO62Y+SaG5fvOUB0eAZgeHpBgyw=; b=t7zRFPxoxiH36zLj+dxN8mSVJ9/9xwsFsXO1d9XBRJwL4rLaQa+WcZ7ovFxjN766XZ 7qtSAr2tD52wRGxQGUyjwoMd+I3qcgT6NVIE00EzgmZQx54s0hVcri7PiQcYz9ED2ShK JgLQ9lTAF+rxRTI20c3nMrG0C6Rfoj4niGy2tDniZr4jvUOR2r1zBIBuefiLqmYzL3zk zlLhuIK4nc5/qqnII2K0a5K7inLrObEv2zaSXK7OgZ1dGUl31X5JvMauRtjyJHB6nLTJ O47ZZ0/oqFdNTF0Dx4V2rVnySaRfEo2n3Oz+HC+g+/fUlGEYGM1AXYc34IIX7QCiQoz+ +uGg== 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 i140si5946680oib.90.2019.12.13.12.55.18; Fri, 13 Dec 2019 12:55:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbfLMUzR (ORCPT + 27 others); Fri, 13 Dec 2019 15:55:17 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:42775 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMUzQ (ORCPT ); Fri, 13 Dec 2019 15:55:16 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MGQWr-1iVdkq2Ao9-00GmsB; Fri, 13 Dec 2019 21:54:57 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter Cc: Arnd Bergmann , Jordan Crouse , Jeykumar Sankaran , Sam Ravnborg , Joe Perches , "Kristian H. Kristensen" , Thomas Gleixner , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH v2 12/24] drm/msm: avoid using 'timespec' Date: Fri, 13 Dec 2019 21:53:40 +0100 Message-Id: <20191213205417.3871055-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SMQNgPIVRwQmcTY5DRfiQVqW9b6fdavzYJig6CP6LZtweyjRbiD 6mCGxP1rZR5pga+x9KqlX9c6PXDBBgTUGKDJ0BZKNHZin6AxQJIq0jYcnvNfnUsFc79qM/e q8qmecpfokP3hq7bAPt5LDfnxYTuvoKmrPS0nS2HU9pnuvh+0wbVT234k8D5E087sBGJcmP i4yEHD4KCli0umxh9A3ww== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:DbQaztQtI+A=:gxrodGEeRggtiphssUm9Us Jq/wlDutot4qEvgTcu7kfZQQQ3iQeN6l/jwOUlHw1Ybnq3VPgMPcTl9strNMqMIzw9JBvSljD C2jPPtCwvmIl6PByLxcmzD+QyHErVxvkZOmoIegYpuQhUqJIzfhj3Kg6RZVgHW4bz1CqibKR6 Ft+KVdpngmtt8UlvfyoTGNfYmprA9eW5mMVLEvqNmCPx0H24nj3frUkSFibwdnsTjWZZz63di tZABpibKZpy0u8d75dZczso0jUzTi7eQxK68axCwzreJDWLNLzMYomhhBrRb0z+C4Bh7wMREh IqmDvEY1RvYXwj0XALqnYz7FFUInslWTRCWa2S3qkZcg0DSj7/GN6q0MEx3pG4szda+yfMRmK J+8eQam1TInOwvydZdgspJK76t8NiIyLnWBR73tNZXBFkwWoljvI7oQwLHLMzuf7IjJQfvbod 6/+GSDtKOqO9r1irukoe/vUnyVZuxagYtaHgrd/VK2u1ToWu05PY1fGxC+WOCC9dmpwvf4Smo Vje6psV+nHPjQ2LbyeSJYMu8+Vyrfb59oJPpTsfY/ssvaM4JnnlPfgIUn4jSfRDwYrToDgzQJ eNDAO7A/aC8WX3IrDLKrEb4NpEi6wEZO59Ax1mICG/9qQMRhieTT0sii3o27R8skBPFa0BThe S3nKTK699n9ObLvefDUa/onIL6mlTOLQ4MG/dwG5bPq1dlUl/NohuJ6Snj3AKNhp0g10qPDEV RQLRhD98PZpi9F6xvPJMoiLcmvHmOz8gK8ZSNJ7ApEvDJzQ6poZfwqLwx8qK+dGt8k0lrFdqS HZ9OGCvIK91CYt69M0Soyrm7cJpKtZhVe4DJdxYaOiRvfLeff/cHHaLOcnwvnj2Q9MNLlsCJS hyaeD68zOSQ+8Ex8yWDw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The timespec structure and associated interfaces are deprecated and will be removed in the future because of the y2038 overflow. The use of ktime_to_timespec() in timeout_to_jiffies() does not suffer from that overflow, but is easy to avoid by just converting the ktime_t into jiffies directly. Reviewed-by: Jordan Crouse Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/msm/msm_drv.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.20.0 diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 71547e756e29..740bf7c70d8f 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -454,8 +454,7 @@ static inline unsigned long timeout_to_jiffies(const ktime_t *timeout) remaining_jiffies = 0; } else { ktime_t rem = ktime_sub(*timeout, now); - struct timespec ts = ktime_to_timespec(rem); - remaining_jiffies = timespec_to_jiffies(&ts); + remaining_jiffies = ktime_divns(rem, NSEC_PER_SEC / HZ); } return remaining_jiffies; From patchwork Fri Dec 13 20:53: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: 181594 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1146590ile; Fri, 13 Dec 2019 12:56:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxxwxH8cJOGVDzIZ3zcNyYrbXG+sFOZ1LngQfLWcdDmVimgPgtrRSrwVlbuTQWkjwltcFi7 X-Received: by 2002:a9d:7094:: with SMTP id l20mr17089713otj.190.1576270617615; Fri, 13 Dec 2019 12:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270617; cv=none; d=google.com; s=arc-20160816; b=RBe1iRfMv8cOT116JCUJXj4rDS7ITA99uokD0rN0KMjtxJyIW9utbTaqNONh3RjT6n LeLtiZHbeh7yZLQ+i8swYgYcVHix3EpxeQ36iOwHABhH2VqUqzP9Ps4yfMm/7XHfrcc4 rcXUf/bhAdbAVKN/TcsVtwyWL1S/T/33AzwlYcBaUstR0bjpMN1VwAMLEcjeY9z9ZBXb UoftGFostkj5M4/x+fA9EHMEk1foGIQ+XPepk7pj5kwFQ+lHy3Piyq9X5zrLte4Ee+qD hv0WiaRGLWmLXiv/H77hZAUHccf+5Ffz67+T3M1KWHROmdbaQyXugka8DA+sN9dM5lAq fdkA== 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=3pR8R/8xGB8VZEpJ4oYQ1nXlghI+D8FW4sGz+Mdr+V4=; b=08Uf/ubO8F44dwglLjCX0BHgT4BRPDHzNRt2TiuLHN8LElYH3UUCYWLxC7jfy1fkY8 uaVOyLMYegxVViXvsX0z1+E/9Mw2C3/uNCUqJsFB+92kzUeNR5oq07zw/Q8YMWndq+Or wYIyQO84sovOAqzrodpashSbr02GnRSlBFcdHD6AZIliTjf8y5yfE2WcZw9T7WCkhRul NmzcNrZRuhxuKZhhpJhBfJ0DsT7gm439s/1jfAWCPuTd70ncCKDyjoSiWIg+XE5uDu1j IMfHMfsY7TayqH7AgH86IS1f57f23K87/exVatmhhJ+48jkAAeS6fRejlP9NIsHkg2hz K0LA== 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 z14si5318744oih.89.2019.12.13.12.56.57; Fri, 13 Dec 2019 12:56: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 S1726744AbfLMU44 (ORCPT + 27 others); Fri, 13 Dec 2019 15:56:56 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:48953 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMU4z (ORCPT ); Fri, 13 Dec 2019 15:56:55 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M7sUE-1iatty0MiI-004zAm; Fri, 13 Dec 2019 21:56:24 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "J. Bruce Fields" , Chuck Lever , Trond Myklebust , Anna Schumaker , "David S. Miller" Cc: Arnd Bergmann , Simo Sorce , Eric Biggers , Herbert Xu , Bruce Fields , linux-nfs@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 15/24] sunrpc: convert to time64_t for expiry Date: Fri, 13 Dec 2019 21:53:43 +0100 Message-Id: <20191213205417.3871055-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:RkDeIaFu6tTIaveO+DHQKcjxBAB7BEHoQZvY2uFHzWjSYL9X+Lx mzQe0jVYOkFmWsPcEWpDftiypK700MdwLlAC5qHAnYw/dM8edUwm+Nvgn59UcxvmMnrXtFC BPjnhGYXWorgsajgWORN1DsJp0bCmKmgUk+4B9lqB2Oa400G0AdEjnGetqrNtA3X2c/Cz7w 3gqATfZJ2wxJUqTZA0O+w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:4xIoJv151vc=:EjO59GyBCVMiLbjrWvBAmc P1ThtoYjwjePIQ0tzE2plQ54sqhA06sclv6rfW73/e9ZxajyIfvD/CHxMkAk18L5s/8S73GWJ HcUYGis6cW7xAPt4vqT0YQNqiJtTBelhYL+NTpNEWuHoRStoRYLypFpJPNXAgXavnYJs0IdPy gkgBNDpKsgmL+yBUayrRWobfKhdHffP0LNysiTtzOzx5JmrX57hIdqH2nlHtWOLC/gc+gWNeX RU8BWuFrqw+6hELw1Y0jBvNohB6zZTXX+1/twtli6t/poGfEtrI8mhA4YWlvlmya1kjgW3Qo/ QUGuxQhEEAXcy/D0YmAFM/PxMcM8BAVrvo0MpW8Jo6cB7uSK6GvFZH2hUygcSyjyza09meChQ soXDRXWvgjif8CbzDUbZQs9axsgAWoYJy3Q7rLpg7h3qO0nXv3G4LOCrxoxQNS8Z8XXScjb1r WUdsIvx7vxmSVyNHQxmHduqCUQ5HTVeUvcegoH1RzkKUlVf4pCEMXxuvsWAcvtnYXmfGgZXoH mSVCWIL7x/jAcuDb3fvxpFZZCJh6nWN+2gsN8s0U1l/8vGWF4f3TiAaMVWIPUjFdUSRPtNtsu SNhhqwYQwrDxhpOlX5IFrw9IzhZUwS9j3JTVBTHavWtOhjtkTO/7J1v75RP7RlAKE9AOpMANX e56lfM1GrecgvziKOwlVbqwNaoCWfd5JAvrl36ceFDGXH1AKLvU/ipR1Kob+jY6hdufwmpC2y 985ESbrWyeFUJjkGeEKqiPvobI9ubS6kiA1MUpbHU/dLa0VjQ9euq0eC8WB4qIJVCRVLq7tA1 EN23CSxDp4saTvTzf363IrwVNRFY77HnmVA8qE5f8aUk5H3dq8rPF25okrsT/vdZ/wuyQwDsz NPGrVjQVZ3VWo6XU9RHg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using signed 32-bit types for UTC time leads to the y2038 overflow, which is what happens in the sunrpc code at the moment. This changes the sunrpc code over to use time64_t where possible. The one exception is the gss_import_v{1,2}_context() function for kerberos5, which uses 32-bit timestamps in the protocol. Here, we can at least treat the numbers as 'unsigned', which extends the range from 2038 to 2106. Signed-off-by: Arnd Bergmann --- include/linux/sunrpc/gss_api.h | 4 ++-- include/linux/sunrpc/gss_krb5.h | 2 +- net/sunrpc/auth_gss/gss_krb5_mech.c | 12 +++++++++--- net/sunrpc/auth_gss/gss_krb5_seal.c | 8 ++++---- net/sunrpc/auth_gss/gss_krb5_unseal.c | 6 +++--- net/sunrpc/auth_gss/gss_krb5_wrap.c | 16 ++++++++-------- net/sunrpc/auth_gss/gss_mech_switch.c | 2 +- net/sunrpc/auth_gss/svcauth_gss.c | 4 ++-- 8 files changed, 30 insertions(+), 24 deletions(-) -- 2.20.0 diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h index bd691e08be3b..1cc6cefb1220 100644 --- a/include/linux/sunrpc/gss_api.h +++ b/include/linux/sunrpc/gss_api.h @@ -48,7 +48,7 @@ int gss_import_sec_context( size_t bufsize, struct gss_api_mech *mech, struct gss_ctx **ctx_id, - time_t *endtime, + time64_t *endtime, gfp_t gfp_mask); u32 gss_get_mic( struct gss_ctx *ctx_id, @@ -108,7 +108,7 @@ struct gss_api_ops { const void *input_token, size_t bufsize, struct gss_ctx *ctx_id, - time_t *endtime, + time64_t *endtime, gfp_t gfp_mask); u32 (*gss_get_mic)( struct gss_ctx *ctx_id, diff --git a/include/linux/sunrpc/gss_krb5.h b/include/linux/sunrpc/gss_krb5.h index 02c0412e368c..c1d77dd8ed41 100644 --- a/include/linux/sunrpc/gss_krb5.h +++ b/include/linux/sunrpc/gss_krb5.h @@ -106,9 +106,9 @@ struct krb5_ctx { struct crypto_sync_skcipher *initiator_enc_aux; u8 Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */ u8 cksum[GSS_KRB5_MAX_KEYLEN]; - s32 endtime; atomic_t seq_send; atomic64_t seq_send64; + time64_t endtime; struct xdr_netobj mech_used; u8 initiator_sign[GSS_KRB5_MAX_KEYLEN]; u8 acceptor_sign[GSS_KRB5_MAX_KEYLEN]; diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 6e5d6d240215..75b3c2e9e8f8 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c @@ -253,6 +253,7 @@ gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx) { u32 seq_send; int tmp; + u32 time32; p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); if (IS_ERR(p)) @@ -290,9 +291,11 @@ gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx) p = ERR_PTR(-ENOSYS); goto out_err; } - p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); + p = simple_get_bytes(p, end, &time32, sizeof(time32)); if (IS_ERR(p)) goto out_err; + /* unsigned 32-bit time overflows in year 2106 */ + ctx->endtime = (time64_t)time32; p = simple_get_bytes(p, end, &seq_send, sizeof(seq_send)); if (IS_ERR(p)) goto out_err; @@ -587,15 +590,18 @@ gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, { u64 seq_send64; int keylen; + u32 time32; p = simple_get_bytes(p, end, &ctx->flags, sizeof(ctx->flags)); if (IS_ERR(p)) goto out_err; ctx->initiate = ctx->flags & KRB5_CTX_FLAG_INITIATOR; - p = simple_get_bytes(p, end, &ctx->endtime, sizeof(ctx->endtime)); + p = simple_get_bytes(p, end, &time32, sizeof(time32)); if (IS_ERR(p)) goto out_err; + /* unsigned 32-bit time overflows in year 2106 */ + ctx->endtime = (time64_t)time32; p = simple_get_bytes(p, end, &seq_send64, sizeof(seq_send64)); if (IS_ERR(p)) goto out_err; @@ -659,7 +665,7 @@ gss_import_v2_context(const void *p, const void *end, struct krb5_ctx *ctx, static int gss_import_sec_context_kerberos(const void *p, size_t len, struct gss_ctx *ctx_id, - time_t *endtime, + time64_t *endtime, gfp_t gfp_mask) { const void *end = (const void *)((const char *)p + len); diff --git a/net/sunrpc/auth_gss/gss_krb5_seal.c b/net/sunrpc/auth_gss/gss_krb5_seal.c index 48fe4a591b54..f1d280accf43 100644 --- a/net/sunrpc/auth_gss/gss_krb5_seal.c +++ b/net/sunrpc/auth_gss/gss_krb5_seal.c @@ -131,14 +131,14 @@ gss_get_mic_v1(struct krb5_ctx *ctx, struct xdr_buf *text, struct xdr_netobj md5cksum = {.len = sizeof(cksumdata), .data = cksumdata}; void *ptr; - s32 now; + time64_t now; u32 seq_send; u8 *cksumkey; dprintk("RPC: %s\n", __func__); BUG_ON(ctx == NULL); - now = get_seconds(); + now = ktime_get_real_seconds(); ptr = setup_token(ctx, token); @@ -170,7 +170,7 @@ gss_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text, struct xdr_netobj cksumobj = { .len = sizeof(cksumdata), .data = cksumdata}; void *krb5_hdr; - s32 now; + time64_t now; u8 *cksumkey; unsigned int cksum_usage; __be64 seq_send_be64; @@ -198,7 +198,7 @@ gss_get_mic_v2(struct krb5_ctx *ctx, struct xdr_buf *text, memcpy(krb5_hdr + GSS_KRB5_TOK_HDR_LEN, cksumobj.data, cksumobj.len); - now = get_seconds(); + now = ktime_get_real_seconds(); return (ctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE; } diff --git a/net/sunrpc/auth_gss/gss_krb5_unseal.c b/net/sunrpc/auth_gss/gss_krb5_unseal.c index ef2b25b86d2f..aaab91cf24c8 100644 --- a/net/sunrpc/auth_gss/gss_krb5_unseal.c +++ b/net/sunrpc/auth_gss/gss_krb5_unseal.c @@ -124,7 +124,7 @@ gss_verify_mic_v1(struct krb5_ctx *ctx, /* it got through unscathed. Make sure the context is unexpired */ - now = get_seconds(); + now = ktime_get_real_seconds(); if (now > ctx->endtime) return GSS_S_CONTEXT_EXPIRED; @@ -149,7 +149,7 @@ gss_verify_mic_v2(struct krb5_ctx *ctx, char cksumdata[GSS_KRB5_MAX_CKSUM_LEN]; struct xdr_netobj cksumobj = {.len = sizeof(cksumdata), .data = cksumdata}; - s32 now; + time64_t now; u8 *ptr = read_token->data; u8 *cksumkey; u8 flags; @@ -194,7 +194,7 @@ gss_verify_mic_v2(struct krb5_ctx *ctx, return GSS_S_BAD_SIG; /* it got through unscathed. Make sure the context is unexpired */ - now = get_seconds(); + now = ktime_get_real_seconds(); if (now > ctx->endtime) return GSS_S_CONTEXT_EXPIRED; diff --git a/net/sunrpc/auth_gss/gss_krb5_wrap.c b/net/sunrpc/auth_gss/gss_krb5_wrap.c index 14a0aff0cd84..6c1920eed771 100644 --- a/net/sunrpc/auth_gss/gss_krb5_wrap.c +++ b/net/sunrpc/auth_gss/gss_krb5_wrap.c @@ -163,7 +163,7 @@ gss_wrap_kerberos_v1(struct krb5_ctx *kctx, int offset, .data = cksumdata}; int blocksize = 0, plainlen; unsigned char *ptr, *msg_start; - s32 now; + time64_t now; int headlen; struct page **tmp_pages; u32 seq_send; @@ -172,7 +172,7 @@ gss_wrap_kerberos_v1(struct krb5_ctx *kctx, int offset, dprintk("RPC: %s\n", __func__); - now = get_seconds(); + now = ktime_get_real_seconds(); blocksize = crypto_sync_skcipher_blocksize(kctx->enc); gss_krb5_add_padding(buf, offset, blocksize); @@ -268,7 +268,7 @@ gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) char cksumdata[GSS_KRB5_MAX_CKSUM_LEN]; struct xdr_netobj md5cksum = {.len = sizeof(cksumdata), .data = cksumdata}; - s32 now; + time64_t now; int direction; s32 seqnum; unsigned char *ptr; @@ -359,7 +359,7 @@ gss_unwrap_kerberos_v1(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) /* it got through unscathed. Make sure the context is unexpired */ - now = get_seconds(); + now = ktime_get_real_seconds(); if (now > kctx->endtime) return GSS_S_CONTEXT_EXPIRED; @@ -439,7 +439,7 @@ gss_wrap_kerberos_v2(struct krb5_ctx *kctx, u32 offset, struct xdr_buf *buf, struct page **pages) { u8 *ptr, *plainhdr; - s32 now; + time64_t now; u8 flags = 0x00; __be16 *be16ptr; __be64 *be64ptr; @@ -481,14 +481,14 @@ gss_wrap_kerberos_v2(struct krb5_ctx *kctx, u32 offset, if (err) return err; - now = get_seconds(); + now = ktime_get_real_seconds(); return (kctx->endtime < now) ? GSS_S_CONTEXT_EXPIRED : GSS_S_COMPLETE; } static u32 gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) { - s32 now; + time64_t now; u8 *ptr; u8 flags = 0x00; u16 ec, rrc; @@ -557,7 +557,7 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, struct xdr_buf *buf) /* do sequencing checks */ /* it got through unscathed. Make sure the context is unexpired */ - now = get_seconds(); + now = ktime_get_real_seconds(); if (now > kctx->endtime) return GSS_S_CONTEXT_EXPIRED; diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c index 30b7de6f3d76..d3685d4ed9e0 100644 --- a/net/sunrpc/auth_gss/gss_mech_switch.c +++ b/net/sunrpc/auth_gss/gss_mech_switch.c @@ -376,7 +376,7 @@ int gss_import_sec_context(const void *input_token, size_t bufsize, struct gss_api_mech *mech, struct gss_ctx **ctx_id, - time_t *endtime, + time64_t *endtime, gfp_t gfp_mask) { if (!(*ctx_id = kzalloc(sizeof(**ctx_id), gfp_mask))) diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index c62d1f10978b..0c3e22838ddf 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -436,7 +436,7 @@ static int rsc_parse(struct cache_detail *cd, int id; int len, rv; struct rsc rsci, *rscp = NULL; - time_t expiry; + time64_t expiry; int status = -EINVAL; struct gss_api_mech *gm = NULL; @@ -1221,7 +1221,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd, static atomic64_t ctxhctr; long long ctxh; struct gss_api_mech *gm = NULL; - time_t expiry; + time64_t expiry; int status = -EINVAL; memset(&rsci, 0, sizeof(rsci)); From patchwork Fri Dec 13 20:53: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: 181595 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1146864ile; Fri, 13 Dec 2019 12:57:16 -0800 (PST) X-Google-Smtp-Source: APXvYqzB5AmjQ0MFF62/hvufWyBau9Su5ClCtEDG5zj6oONK3obkKZmm+m6ScStMlkaKWYCRMno+ X-Received: by 2002:a05:6830:1bd5:: with SMTP id v21mr17700917ota.154.1576270636418; Fri, 13 Dec 2019 12:57:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270636; cv=none; d=google.com; s=arc-20160816; b=TWIGwplv6E/u7H32RtM3IuCQnp3td3xtOdunn8BqGsCrXFvXlJZQ4GY0DEgJoczArt QONSndrfjLpsOfCA2meAE3GzCR9OzmvRqMfVh3GZ0oql18rh0VsbRT404UPU67OcXztp WlpDJ2OOdgW0S3N8mDCfhrA1fdCJ6mP/g+FbZ6ka9LhAvNFi/bYDPV2kTJ5QhfFfLEkZ 8f3waM1t8XQ4gVE+0X/HaRgPMSYiEom22R3ubqiAUwlGKolYWiPXYZWxOwfRxNjuw7ba 3UwrRskrQBDnAtt00nVQ6supBCAQYD8ojQODnjMzMjjZVU7BlmnmUS1/bBLlrSTgXCT+ ILfA== 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=Di06DwfsCBH2FUj1yiizMoTNwNOLo5v+Ssj1uvgbGAY=; b=fAWvG9mO7jAx3LwYQB9IblHEpS1hARZh23VLdxFrvfiNp7VKZNsNSakiY5SUf4dAry CByEsEDKf+FiykHxDmBNZnZnWKnrdxx2/mu2z05NX+4w3hOqkdVz0m0o4+geSX1gqsgj xEVKKTwzNrSlRkoYT/l3B6mTZaQCLObbO5x9HBS0yfHYRZwg0WxJTY0HyyZGVfuayl88 MA66B4hUcNAsI9lcWR4Y6xonLWBSe5+rvuuzZGBFGQVMltj8bpYY3oznfNU207Ge8l+7 MW2lIM4KB7UBofNeHx/P2vs9H9zFfrNu5yIfcBkrUMVK90V3TIgDUz3sHmpJ8JUNoCzR 5eSA== 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 y130si5864840oiy.28.2019.12.13.12.57.16; Fri, 13 Dec 2019 12:57:16 -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 S1726784AbfLMU5P (ORCPT + 27 others); Fri, 13 Dec 2019 15:57:15 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:47911 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMU5O (ORCPT ); Fri, 13 Dec 2019 15:57:14 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1Macf4-1i8Ard27AI-00c9CC; Fri, 13 Dec 2019 21:56:47 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "J. Bruce Fields" , Chuck Lever , Trond Myklebust , Anna Schumaker , "David S. Miller" Cc: Arnd Bergmann , Thomas Gleixner , Jeff Layton , linux-nfs@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v2 16/24] nfs: use time64_t internally Date: Fri, 13 Dec 2019 21:53:44 +0100 Message-Id: <20191213205417.3871055-7-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zU579cGLtM2BwOX2L6/aBNJm2mG2LNJX5rJZryF/qIu0irH6BiF ZY/JjteGsij9vQsWk3Dj+aew3UprVZlgGfztwzz6xul+TAEV6K79wojrGUoIE8ZCzm5WE6j 8KBq0afuO2eCyU1AwnwovRQvXboZv/LEA8qVC0DirLx+zt/KcYbbbSL8JVLt6310oGaM2Kk wTDJ99kbGOJq5qwuAogxQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:EWtUItQVyk0=:EOA+z3Iv+IOZwyevr7KVIP jXwQMOg+cf5aR7Jh0dtXDGqvIqvAiYH42nbT4N3oC7mHEoSEXLoQFNTdMufsa4OIewrZoMCh2 z14/rjfPVlV7A76zSvP2NU+ifgLGFT4RtGHITc9KGom0dLiYiFVhj1LXcTNUbZGo3jnbDQfyF lhmR1Pd5Yarq/LR56qFXgJ+TtWEiiCK1ZO9FT9gQaAGzJ6erSY2mgrgIiPQ2cbUAS0gXAofRu tlHCJXgIviZNGo2EqYzHEEIfpDAwf4BFarVXnPd1Z56HzTMbnREo3yws4u5+3hXPntj7EVOKp /PGwgcytxz55P/iDOI7hPx8PB6F/GMe1gcFESzrTAu+ExTDcGCRiIyMP6ziYU/IfmZ4YsHAeE Fx9Z2P10MxSAZ/gqLW+zoKnMG/9t5Jwz7y1tVCUtRM4eHE0tT1bk45QT5+0EgLuCWAZrIxeBX Ohe3yU0QyP7OVGZ0PnSbd8jUENV5oImZlviqvOFv4oFtGA3O7DqSprNeWiogEpn2KMkyL+nB+ cyPWeOYbj6ZzvtMEPiQTL3/+OtPBXQQxAZEoUIKe2FJgrdCJYT7db9MwpT6KJ9JU2RHxpfvBk D/M18UAr3iZKTtWBuXwO75l46mCt8+lOFuu+9Yzh7L8pKgWEt5gLasRYxuHCfa5axA4Z8fR9W 9h/ibWkPpGhTROhXarsgmgq5Su2Jz10DR01iRLwEIlKT9pCr/qLoHDLc6Y7XZwtaLTFB3Pfpz 6ZXkXkvXy8c4da0vU093frsZO8cbMF/DZwjvYozTkWnRr5fF9JTK2gOmONFEMf8ifaSrgiecN fapJ4Wkjez2Pjkn25MwYRSnoKzJCaA2lUEOwHtMsf9ks8XSU4VhqPVDcR82w3vEhdBGlHp3Mq /Ap8N6uIIZ8R3+xZbJ9g== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The timestamps for the cache are all in boottime seconds, so they don't overflow 32-bit values, but the use of time_t is deprecated because it generally does overflow when used with wall-clock time. There are multiple possible ways of avoiding it: - leave time_t, which is safe here, but forces others to look into this code to determine that it is over and over. - use a more generic type, like 'int' or 'long', which is known to be sufficient here but loses the documentation of referring to timestamps - use ktime_t everywhere, and convert into seconds in the few places where we want realtime-seconds. The conversion is sometimes expensive, but not more so than the conversion we do today. - use time64_t to clarify that this code is safe. Nothing would change for 64-bit architectures, but it is slightly less efficient on 32-bit architectures. Without a clear winner of the three approaches above, this picks the last one, favouring readability over a small performance loss on 32-bit architectures. Signed-off-by: Arnd Bergmann --- include/linux/sunrpc/cache.h | 42 +++++++++++++++++-------------- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- net/sunrpc/cache.c | 16 ++++++------ net/sunrpc/svcauth_unix.c | 10 ++++---- 4 files changed, 37 insertions(+), 33 deletions(-) -- 2.20.0 diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h index f8603724fbee..0f64de7caa39 100644 --- a/include/linux/sunrpc/cache.h +++ b/include/linux/sunrpc/cache.h @@ -45,8 +45,8 @@ */ struct cache_head { struct hlist_node cache_list; - time_t expiry_time; /* After time time, don't use the data */ - time_t last_refresh; /* If CACHE_PENDING, this is when upcall was + time64_t expiry_time; /* After time time, don't use the data */ + time64_t last_refresh; /* If CACHE_PENDING, this is when upcall was * sent, else this is when update was * received, though it is alway set to * be *after* ->flush_time. @@ -95,22 +95,22 @@ struct cache_detail { /* fields below this comment are for internal use * and should not be touched by cache owners */ - time_t flush_time; /* flush all cache items with + time64_t flush_time; /* flush all cache items with * last_refresh at or earlier * than this. last_refresh * is never set at or earlier * than this. */ struct list_head others; - time_t nextcheck; + time64_t nextcheck; int entries; /* fields for communication over channel */ struct list_head queue; atomic_t writers; /* how many time is /channel open */ - time_t last_close; /* if no writers, when did last close */ - time_t last_warn; /* when we last warned about no writers */ + time64_t last_close; /* if no writers, when did last close */ + time64_t last_warn; /* when we last warned about no writers */ union { struct proc_dir_entry *procfs; @@ -147,18 +147,22 @@ struct cache_deferred_req { * timestamps kept in the cache are expressed in seconds * since boot. This is the best for measuring differences in * real time. + * This reimplemnts ktime_get_boottime_seconds() in a slightly + * faster but less accurate way. When we end up converting + * back to wallclock (CLOCK_REALTIME), that error often + * cancels out during the reverse operation. */ -static inline time_t seconds_since_boot(void) +static inline time64_t seconds_since_boot(void) { - struct timespec boot; - getboottime(&boot); - return get_seconds() - boot.tv_sec; + struct timespec64 boot; + getboottime64(&boot); + return ktime_get_real_seconds() - boot.tv_sec; } -static inline time_t convert_to_wallclock(time_t sinceboot) +static inline time64_t convert_to_wallclock(time64_t sinceboot) { - struct timespec boot; - getboottime(&boot); + struct timespec64 boot; + getboottime64(&boot); return boot.tv_sec + sinceboot; } @@ -273,7 +277,7 @@ static inline int get_uint(char **bpp, unsigned int *anint) return 0; } -static inline int get_time(char **bpp, time_t *time) +static inline int get_time(char **bpp, time64_t *time) { char buf[50]; long long ll; @@ -287,20 +291,20 @@ static inline int get_time(char **bpp, time_t *time) if (kstrtoll(buf, 0, &ll)) return -EINVAL; - *time = (time_t)ll; + *time = ll; return 0; } -static inline time_t get_expiry(char **bpp) +static inline time64_t get_expiry(char **bpp) { - time_t rv; - struct timespec boot; + time64_t rv; + struct timespec64 boot; if (get_time(bpp, &rv)) return 0; if (rv < 0) return 0; - getboottime(&boot); + getboottime64(&boot); return rv - boot.tv_sec; } diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 0c3e22838ddf..311181720d79 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -203,7 +203,7 @@ static int rsi_parse(struct cache_detail *cd, char *ep; int len; struct rsi rsii, *rsip = NULL; - time_t expiry; + time64_t expiry; int status = -EINVAL; memset(&rsii, 0, sizeof(rsii)); diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index f740cb51802a..d996bf872a7c 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -42,7 +42,7 @@ static bool cache_listeners_exist(struct cache_detail *detail); static void cache_init(struct cache_head *h, struct cache_detail *detail) { - time_t now = seconds_since_boot(); + time64_t now = seconds_since_boot(); INIT_HLIST_NODE(&h->cache_list); h->flags = 0; kref_init(&h->ref); @@ -139,10 +139,10 @@ EXPORT_SYMBOL_GPL(sunrpc_cache_lookup_rcu); static void cache_dequeue(struct cache_detail *detail, struct cache_head *ch); -static void cache_fresh_locked(struct cache_head *head, time_t expiry, +static void cache_fresh_locked(struct cache_head *head, time64_t expiry, struct cache_detail *detail) { - time_t now = seconds_since_boot(); + time64_t now = seconds_since_boot(); if (now <= detail->flush_time) /* ensure it isn't immediately treated as expired */ now = detail->flush_time + 1; @@ -274,7 +274,7 @@ int cache_check(struct cache_detail *detail, struct cache_head *h, struct cache_req *rqstp) { int rv; - long refresh_age, age; + time64_t refresh_age, age; /* First decide return status as best we can */ rv = cache_is_valid(h); @@ -288,7 +288,7 @@ int cache_check(struct cache_detail *detail, rv = -ENOENT; } else if (rv == -EAGAIN || (h->expiry_time != 0 && age > refresh_age/2)) { - dprintk("RPC: Want update, refage=%ld, age=%ld\n", + dprintk("RPC: Want update, refage=%lld, age=%lld\n", refresh_age, age); if (!test_and_set_bit(CACHE_PENDING, &h->flags)) { switch (cache_make_upcall(detail, h)) { @@ -1404,7 +1404,7 @@ static int c_show(struct seq_file *m, void *p) return cd->cache_show(m, cd, NULL); ifdebug(CACHE) - seq_printf(m, "# expiry=%ld refcnt=%d flags=%lx\n", + seq_printf(m, "# expiry=%lld refcnt=%d flags=%lx\n", convert_to_wallclock(cp->expiry_time), kref_read(&cp->ref), cp->flags); cache_get(cp); @@ -1477,7 +1477,7 @@ static ssize_t read_flush(struct file *file, char __user *buf, char tbuf[22]; size_t len; - len = snprintf(tbuf, sizeof(tbuf), "%lu\n", + len = snprintf(tbuf, sizeof(tbuf), "%llu\n", convert_to_wallclock(cd->flush_time)); return simple_read_from_buffer(buf, count, ppos, tbuf, len); } @@ -1488,7 +1488,7 @@ static ssize_t write_flush(struct file *file, const char __user *buf, { char tbuf[20]; char *ep; - time_t now; + time64_t now; if (*ppos || count > sizeof(tbuf)-1) return -EINVAL; diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 5c04ba7d456b..04aa80a2d752 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -166,7 +166,7 @@ static void ip_map_request(struct cache_detail *cd, } static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class, struct in6_addr *addr); -static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time_t expiry); +static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, struct unix_domain *udom, time64_t expiry); static int ip_map_parse(struct cache_detail *cd, char *mesg, int mlen) @@ -187,7 +187,7 @@ static int ip_map_parse(struct cache_detail *cd, struct ip_map *ipmp; struct auth_domain *dom; - time_t expiry; + time64_t expiry; if (mesg[mlen-1] != '\n') return -EINVAL; @@ -308,7 +308,7 @@ static inline struct ip_map *ip_map_lookup(struct net *net, char *class, } static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, - struct unix_domain *udom, time_t expiry) + struct unix_domain *udom, time64_t expiry) { struct ip_map ip; struct cache_head *ch; @@ -328,7 +328,7 @@ static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm, } static inline int ip_map_update(struct net *net, struct ip_map *ipm, - struct unix_domain *udom, time_t expiry) + struct unix_domain *udom, time64_t expiry) { struct sunrpc_net *sn; @@ -491,7 +491,7 @@ static int unix_gid_parse(struct cache_detail *cd, int rv; int i; int err; - time_t expiry; + time64_t expiry; struct unix_gid ug, *ugp; if (mesg[mlen - 1] != '\n') From patchwork Fri Dec 13 20:53: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: 181596 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1146998ile; Fri, 13 Dec 2019 12:57:22 -0800 (PST) X-Google-Smtp-Source: APXvYqx3Ya8bIHOs/sAtytJlDxRIJS2T7Y8fs7Y6XfQf8kSr2TMVpaA7mQXgF3BnlsMWlCw+rO3s X-Received: by 2002:a05:6830:1047:: with SMTP id b7mr17357575otp.77.1576270642441; Fri, 13 Dec 2019 12:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270642; cv=none; d=google.com; s=arc-20160816; b=Y9zkqylmpHPMgZinLy6kOEa2Z8aWS/kGQnnDkCse3m0yWv2Zr2YbKSen2Klhbjil9+ vNl9xU1s3CcJWrL7SiT3QGtr1SrcIycM8AvfmR8MGsvciRT7aM07cZmRLDAbtE83YRCK YQ0hD7aXG1bk2niUik44TldUrtBrZn4hLX17JMYcbJ72EJ3v5J7qByqgpGqI21xTQ6kb rIflX85gMtL2QcCYPhy4x6sR4zE4O1MzmrjULr4xo/OrIhBdFDZ4WZrXMPWZEWI+/6WH 2vOCoH9FhOsTvhvalMfNav9QLt4wviZiPLoZdgA+LfVGkqk+5OX/Oq9YWZbP3fU3zTvw mB9A== 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=KUensJ9kF4GJ2+XTN7dVeLzmyZhtVlhTlLTvDC3iBfs=; b=Axb7Eu6THZnT1/bUudAUwxROzn/IsWiNbyOLy1fefvu8PhTCvLk4CY3anqnCaBYcm9 3yDvFQUMU5WW0eYXs9FfWU3ml7xY0mn37diCWY6eM/Q144UkZ2fAM/ELQDgztDWFu3bE m9Xs6oTz1zvPsm0FZ1WzENaoopuyWy+tcswCoLz9mffsZPOFdcge3+BsDj8toCBTe2xH +7Q6XJLTvk02aAUIJVpTObE3yFaolVn6Y/6Og3LhdIeTGxW4gOGv64vinBn8944fYUKe VZyPGmGVzPiLOHaIP8iYSmHLUWOw/Q/p2QS7GXfJXkOkmhHFFIj8xaNQq/GxLmV9Whx6 EKJg== 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 y130si5864840oiy.28.2019.12.13.12.57.22; Fri, 13 Dec 2019 12:57:22 -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 S1726802AbfLMU5V (ORCPT + 27 others); Fri, 13 Dec 2019 15:57:21 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:35455 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMU5T (ORCPT ); Fri, 13 Dec 2019 15:57:19 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MJVU0-1iQOTT1xgu-00JvWU; Fri, 13 Dec 2019 21:56:59 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Trond Myklebust , Anna Schumaker Cc: Arnd Bergmann , Chuck Lever , Donald Buczek , Olga Kornievskaia , linux-nfs@vger.kernel.org Subject: [PATCH v2 17/24] nfs: fix timstamp debug prints Date: Fri, 13 Dec 2019 21:53:45 +0100 Message-Id: <20191213205417.3871055-8-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:BPsskpb/goZHuGLwGJ1x2XQfxqhv8DLj+WuA9nQWoEVfSqSeN/I fGS/jLREazuK14w8zqELuRQegSYQUDL6R7qd9r8qD2KYJH0Q89uLdDaZnB9tbLT6UAgENTz TWgdOq04Zz9t0gBVAkaD5CKbQ7IbUyd/dHvLHlyi+8l2D+LVQzlW8wqlsVFa7A35ZaxNiSS 8woZIL/pUXR/kABRL3EKw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:xADCT6UJRW4=:JIwiGJh/B+y32axL9wUyNJ mjMgZReUcesvl3rK9VNPN7H7n0lKP+2Heseh3H+PWkrpcUxSno872ZyWD+HXSbXUsXvDVmWlU ig9CBKV6/cf5i9EDx0byURIgX1kKuWCbXhgeDXrmDXiLusJoGlGMA83RsQ3ramscBXiyaEblb D3nXD+1TnHlktvnVFSwTCnd4Wio+7K9IIRC/zjvgw6wPpbyygztBemXwrpfvN2/7HKrxWsY8q RZRDj7sroLSnxryn6Pi9lA5vbOJ3INa9oeNt0gYnXTdAnsP2aqYP1IoxUVr/W9Mjh0q4kpn1C ZqJ2h0JWDqzN6j995ub5QpjfcFaLQBKwfKs6mXhWw9Jx6h5VHYqV4TVAAClpIFRBzSCi2/YeA xD6DkKzlnI6G4vt6nLZEinve0xmdmQbyk6Vv4tIxJnSQ6bB17HUAEBI3P/wQqcs9YJKycCDe4 mf8ZsUH1Bk0c1fAgWjGVYI0drUefdMJgLVwavx4k8LL/vbqDKa9Dsb01RQD71dy57zBMALhhR uh0AlgKg6D21L+P6Tv8Df0sA890mAZu3u4Vmz9/2qGiiDp/Iars3qMCEypnKNDi3D25pbH/JZ 0DYshkArsJ+EWwVPv2QONE9m6ZfKnvmJZZmebQIuK/Te/qD0Kt8FosRTTaW1Bq0eybyokrfwa 1ac9L//a2fafyHGLcYqWhOEf8jVUtbQtWeuGrqryQKpGrP3POskes4D7vZ3giT4bxZALcIerX bWMKud/4acgIrU2prf9iC6PWhnUa5iTWPuVwjbufxNtKyVAXSD/W1buvBQMhx1wec4Us5Fy0P B6/vivSsZHDVXYMGDs+pJ+26UNZ1yYdF3QRjIDeCiZIKjjcwloFKxJt4izKJQWp+i41bdrjS+ XPh+ftuT+CCVyLu+OMZw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Starting in v5.5, the timestamps are correctly passed down as 64-bit seconds with NFSv4 on 32-bit machines, but some debug statements still truncate them to 'long'. Fixes: e86d5a02874c ("NFS: Convert struct nfs_fattr to use struct timespec64") Signed-off-by: Arnd Bergmann --- fs/nfs/nfs4xdr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.20.0 diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 936c57779ff4..728d88b6a698 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -4097,7 +4097,7 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, str status = NFS_ATTR_FATTR_ATIME; bitmap[1] &= ~FATTR4_WORD1_TIME_ACCESS; } - dprintk("%s: atime=%ld\n", __func__, (long)time->tv_sec); + dprintk("%s: atime=%lld\n", __func__, time->tv_sec); return status; } @@ -4115,7 +4115,7 @@ static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, s status = NFS_ATTR_FATTR_CTIME; bitmap[1] &= ~FATTR4_WORD1_TIME_METADATA; } - dprintk("%s: ctime=%ld\n", __func__, (long)time->tv_sec); + dprintk("%s: ctime=%lld\n", __func__, time->tv_sec); return status; } @@ -4132,8 +4132,8 @@ static int decode_attr_time_delta(struct xdr_stream *xdr, uint32_t *bitmap, status = decode_attr_time(xdr, time); bitmap[1] &= ~FATTR4_WORD1_TIME_DELTA; } - dprintk("%s: time_delta=%ld %ld\n", __func__, (long)time->tv_sec, - (long)time->tv_nsec); + dprintk("%s: time_delta=%lld %ld\n", __func__, time->tv_sec, + time->tv_nsec); return status; } @@ -4197,7 +4197,7 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, str status = NFS_ATTR_FATTR_MTIME; bitmap[1] &= ~FATTR4_WORD1_TIME_MODIFY; } - dprintk("%s: mtime=%ld\n", __func__, (long)time->tv_sec); + dprintk("%s: mtime=%lld\n", __func__, time->tv_sec); return status; } From patchwork Fri Dec 13 20:53: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: 181597 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1147173ile; Fri, 13 Dec 2019 12:57:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzzYMgYoimExyVrwWXWcWCsCxhUPAY1yo7dND1EVB5SbYtGGiwtx61JnsE7KnV6bKUHCyLv X-Received: by 2002:a05:6830:1607:: with SMTP id g7mr16819975otr.320.1576270653969; Fri, 13 Dec 2019 12:57:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270653; cv=none; d=google.com; s=arc-20160816; b=QBZUlQBmo4gPabX2xNyt3Sf44LbU7CXOqiR0kE319K/ROEf1tR7mmPVX336z8GQxdO L3HO8J/6P2ILPOsbwfCF2M7F0L9GU+0ln8G3YeNGNRSaR3zQMMRTA29ymRgKfjvlEBne ZnFq2wQKczXEmKwUVolsLl5rlL4b8zB2qcP+7+bnqIdle8OxACxM68v6P0y3ODIygRER k/v49GVhU+Fwls9l+mM8HoNIymnL9K0XfOBzimLrtms+XY1pB2+HMj+iksLmMOhUJwF1 iroabapSHU+P4EaWRm7U0fkkX1Vxiz0MRlV/BFIL5NEUGc+PZFkdB8dyTOUIROgwMnwC RZOA== 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=UIcpQU5ThaBTR9M+FoOKr6ZgZbc2LPgn8fhLykCRIk8=; b=JVLi7eVjO0mjfL0D29BzO0qgc7DPFKTP/U0Grv9WgBg7REDBjSIbMO8GC1+mfgG9vX s0voY5PELBpiMi3foOOOOwdYdp55PW+mhl2Omm9qK00oVvXsKLJfHOO3nI3h4OmltW5J m2wJHTOIgSYJS0T8oy9sxUYPWXum2udAhc2YPQTRWpNajt7LqKXXkSQdG7/R6UQo4sk+ QGPtW9DEiwbqV4uxJnSPjTmT7duS+t/qMDWwuPwlwSDqROfzi3HHqgIWYIKKZWlgnb7q 02wMzcDNb5Tz7Eb3vYECnmlmZzAb2Pyrq7p9VW+CGnOwG/HazpRWteEAZkZTRNmK11A6 sTmw== 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 z1si5718352otp.70.2019.12.13.12.57.33; Fri, 13 Dec 2019 12:57:33 -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 S1726818AbfLMU5c (ORCPT + 27 others); Fri, 13 Dec 2019 15:57:32 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:33731 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMU5b (ORCPT ); Fri, 13 Dec 2019 15:57:31 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MCbZL-1iWCwj47Xf-009dzd; Fri, 13 Dec 2019 21:57:15 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Trond Myklebust , Anna Schumaker Cc: Arnd Bergmann , David Howells , Thomas Gleixner , linux-nfs@vger.kernel.org Subject: [PATCH v2 18/24] nfs: fscache: use timespec64 in inode auxdata Date: Fri, 13 Dec 2019 21:53:46 +0100 Message-Id: <20191213205417.3871055-9-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:eSpA+PeGzcN5/q+tSCYMNqYwum00xsr3wrwDajwhj/LcbNxeqj3 xpZEUffRgySY5dIEMfYLZyJqNTCruiE0MMz9YpW+jOORPjSIStKzr+8z+H6mQz25URpuODB e223MW7cvFYZ6dCuCXKvbkvrQb1nYpoztuLlysTOh0wDCnrfnvi2ilsZvdfcRnKOXXny7wU mDag+0g9ojpjFZcDv7n6g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:yxdt9MqnWt4=:OBts36wUuwCQus2XQkhzGl pKenNFFAD2FTUrYDyhA0zUblisj/ayGPpSpIezzv4UghyEyenxubcoF0Y3RWMPxVm9ySafB4x vLpZl2UwLbcB0u7S/rlBsatGDaEfLaHuA7bDb3u423+pcTA5dNV489y+mISiNaQk6HxstKYdG VlN+/20BwC7KlJJnK2esD7qWzG//1shkBYOfcUAgvkRcaTUnHZIDK56Kqh0YzZLkGE/A3p98/ mK4QWPy4in+qxK0hMjPw10Jo0doBm9saNK8iWLVlEGURKFkfRRY+Oz55hEfEpv/pi1Pey71zZ e3D1hYzUbTM2TO3i99t586jcPyPnbdarRFopA++nL3W3wfuSSal+pPUoToKJR3Bj0s2GrjmCF yA48A/vJhhaqUdPnCKaeJrbo/Zy7ZyJb+x9kvA29zpWzr2Zm6qX71hjujr73DjD0Y1BtzUF3P FvfSAr1TfJj19qQFr2SJ6UTPapu8emgETmyNB7ryIecNwXa+zaWaBUoCB9XUrRXGPYnQC3gnw B7204zKLOcSD1ByV/Y9xXZwsXYGWPdupyrbr9UVcTRy9c3YrwXJOtF9dAizbBAjslO+p3HMfu kymi02S/6REd3ikGqh6oF15QgH01KDrb1/yCBAovM4WMXHh/a1jBS1vDr4bKzd7oS0IV+fkBJ MH0vtZdstx/2/Syy+IVtpy1+n2En+Yk8upOzPQQIil5SVafifFqbP9uGh1hEiQZhAy3MKu9df lSPWgHbQ80g8idvOlDQXWx9TL8R0Mp8HUAqxudJRd7p9VXbEw9aeZXtZfx6myuY8ZYLryhhne spgQXL7f0P/FfsWb7otpMXRbNmt0e9zc5KvAsS10NNdkM+6CEhQvuZWu9JxZFEpDGD4lfigiW s8q1TGli8fGxZvftiCZw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org nfs currently behaves differently on 32-bit and 64-bit kernels regarding the on-disk format of nfs_fscache_inode_auxdata. That format should really be the same on any kernel, and we should avoid the 'timespec' type in order to remove that from the kernel later on. Using plain 'timespec64' would not be good here, since that includes implied padding and would possibly leak kernel stack data to the on-disk format on 32-bit architectures. struct __kernel_timespec would work as a replacement, but open-coding the two struct members in nfs_fscache_inode_auxdata makes it more obvious what's going on here, and keeps the current format for 64-bit architectures. Cc: David Howells Signed-off-by: Arnd Bergmann --- fs/nfs/fscache-index.c | 6 ++++-- fs/nfs/fscache.c | 18 ++++++++++++------ fs/nfs/fscache.h | 8 +++++--- 3 files changed, 21 insertions(+), 11 deletions(-) -- 2.20.0 diff --git a/fs/nfs/fscache-index.c b/fs/nfs/fscache-index.c index 15f271401dcc..573b1da9342c 100644 --- a/fs/nfs/fscache-index.c +++ b/fs/nfs/fscache-index.c @@ -84,8 +84,10 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data, return FSCACHE_CHECKAUX_OBSOLETE; memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c index 3800ab6f08fa..7def925d3af5 100644 --- a/fs/nfs/fscache.c +++ b/fs/nfs/fscache.c @@ -238,8 +238,10 @@ void nfs_fscache_init_inode(struct inode *inode) return; memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); @@ -263,8 +265,10 @@ void nfs_fscache_clear_inode(struct inode *inode) dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie); memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; fscache_relinquish_cookie(cookie, &auxdata, false); nfsi->fscache = NULL; } @@ -305,8 +309,10 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp) return; memset(&auxdata, 0, sizeof(auxdata)); - auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); - auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); + auxdata.mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; + auxdata.mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; + auxdata.ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; + auxdata.ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; if (inode_is_open_for_write(inode)) { dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi); diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h index ad041cfbf9ec..6754c8607230 100644 --- a/fs/nfs/fscache.h +++ b/fs/nfs/fscache.h @@ -62,9 +62,11 @@ struct nfs_fscache_key { * cache object. */ struct nfs_fscache_inode_auxdata { - struct timespec mtime; - struct timespec ctime; - u64 change_attr; + s64 mtime_sec; + s64 mtime_nsec; + s64 ctime_sec; + s64 ctime_nsec; + u64 change_attr; }; /* From patchwork Fri Dec 13 20:53: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: 181598 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1147303ile; Fri, 13 Dec 2019 12:57:42 -0800 (PST) X-Google-Smtp-Source: APXvYqyU51L6BQa/Z027fBqGgVejksNjMcyWmgB2FUEX6S0PnkARFV1SfDxe9mfQqKQY54HBG+m/ X-Received: by 2002:a05:6830:1582:: with SMTP id i2mr17402640otr.50.1576270662368; Fri, 13 Dec 2019 12:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270662; cv=none; d=google.com; s=arc-20160816; b=iDnR/tKmCuByJdw/28N9/N724lQqV1+3t7w2jNIIgcPF/6Ug3a5jL5PBTjmrccp+Pf xnnlHa5ssx/gMJr/P3aFGbSpAgQ4xKWeXZEXMbo2NOHcFN4ruK/L8P4U2heCJ7uaCZZ0 I/G5cGAT1jA5FK4Irl0NPQrc1PyxOYdT77UQW0zTgoZoqckGiX9kfMpf/tf5Fk/LuP5N ybzGrIYMBaUgLiJU0RNqzWiCNHYHu33rXboRZT7LPvZ7v6oDVaucr1eiIIYFHixbygFW D3FwAg7KG7r6Tf5CV+sMi1v1v1RFfEmlyh66PxWACJukvrDWE1MK1LUJjFX0ZalFpMBf q0JQ== 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=BE8tX3r7DxSfvGij0/paxA5e5izScGozc03oRhGhjow=; b=xDgTLXLE2d8U2cz6Jfl8frthaNhmNyvXpS4rYX+77iUAUI2l+xTysiPdWllC0eZ6Vz XfsewiDv53mUc+lyH+RhOvMsAljmVHcO71W3dk9mkBFRigl7lTFT6p6bCXopn+zPCE5u 1gTM3u8T4F69Ds/vc1bXK9bDJctDbFpoGHTVBQt+BHUjFGiBwxOz915fap1Sqv9VfcJG Ky5PFKCkPlYipwAYhC+8evnxWvtpPoLxHyPdFYDhacVATnh93bvwLjI+zFrbDMcpCR3w BhpPmHYXJKYc/PZSOD2ctt1dIY0NxGHZanJQxm9qBK3C/QthXRqzkc+XnpNDL5V3a//c EMKw== 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 z1si5718352otp.70.2019.12.13.12.57.42; Fri, 13 Dec 2019 12:57: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 S1726836AbfLMU5l (ORCPT + 27 others); Fri, 13 Dec 2019 15:57:41 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:55425 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMU5k (ORCPT ); Fri, 13 Dec 2019 15:57:40 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M2w0K-1ijAJy1eIO-003Mbu; Fri, 13 Dec 2019 21:57:30 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "Darrick J. Wong" , linux-xfs@vger.kernel.org Cc: Arnd Bergmann , Brian Foster , Eric Sandeen , Nick Bowler Subject: [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Date: Fri, 13 Dec 2019 21:53:47 +0100 Message-Id: <20191213205417.3871055-10-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zARXgYKok4zeFDeeiNI16bU/sUy4YFIaNYCQJhqKBzQvtO+A17j v4tP1EL/FypfHgRghMWum3GsKwt3bSsFh+LQlXfZ8b1QoXAeO/eXJeoUue+k/qwEXtW3KQt 8CymFTBFACC8PMqkvogi/8JqezrnKFM7ZCyKZRi4H0KE11VQzGJsVCZgVf1eHP+T/QD+CG0 QqYUBx+tj3Lzwj6dluayA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:KuBqyk8mLpI=:DXXot5F8i3KR2QR2b5njA0 C5sUb6IXLZGwy3iRjXzZtPcQ0bKQ98ph2rn+5bOAuE1WA2E+2DRWnJJwJBLnk7uF/5alcwxq4 pw1I7k3cyzP0yWzHOgS58+gxZpIyQWP3bGUZZmYFdPuRnwOpIu/r2v8vUv5dNxfKiQwdi9cH0 fjOQ0dEq8+9hs4nrEg1rfLtCebS0M6cjEiTK9Wrt3/1XHGqfDbFQTY3MUMMx1vhfBw/ya46HS 8d55sKQU+FiWDcBt4fRWxUff/lKINLgvy3w49NzDtn1ZYAxMFYK0ExbRxoc9f/lsR++hpy/kM EzHD7K5n9vG2kY4S+oqQ+5Dbpo0JwcACUDE1GReG9NDvCoZvj7l2K3NSJjCCFHTh4mc875uvg 2Z3ZPzuSPl8EFMO8SXyeuESMwXOVZCjqSY9YVkaBxJFPGg5Oq3N+3OWILmR44OvK/bioeHV/7 cFeH0oJM0xLojwAFlNdyMi7s5bn7erLfG7ZzBfvKWxbxT4u+jZYvHS4E+Wof/p+yQOi+eKhEZ InFbWlGZu0VLsmLuu8Gbxtkz+dbyEegQ6pzqR3Dgp3boxgCVmksoKok2pTcahOlUXGxH+kUUa T1+NbB2FCuUBTv7ig9jXs1q11ukMR8Q0lOL3NaWSZXipJGyCIAE3kZloJ+P1Mch6AUh4DSuEt NgFYm0LS/edpWjeMa+I0kb6ujA0GaoeoIqc4ruiaB49lzL6HlHKoaAO/gCWIFg+2X6mf8E9ZE CaO9gEtvqhPOkkWKJM3kbSyN9/TssF0J8NS0KTjcdpuNPSALWSGojoK/MpKxCsC52LDfHOnlz fACIRYflX0kBmHe8Va1nfHfCblPXXBBPcFy8WX5anhd0ChMO8MavG4yqDO9KqJObrVIcJssKB csAnZVpQ8ahGdl4jO+Sg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The compat_time_t type has been removed everywhere else, as most users rely on old_time32_t for both native and compat mode handling of 32-bit time_t. Remove the last one in xfs. Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_ioctl32.c | 2 +- fs/xfs/xfs_ioctl32.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.20.0 Reviewed-by: Darrick J. Wong diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index c4c4f09113d3..a49bd80b2c3b 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c @@ -107,7 +107,7 @@ xfs_ioctl32_bstime_copyin( xfs_bstime_t *bstime, compat_xfs_bstime_t __user *bstime32) { - compat_time_t sec32; /* tv_sec differs on 64 vs. 32 */ + old_time32_t sec32; /* tv_sec differs on 64 vs. 32 */ if (get_user(sec32, &bstime32->tv_sec) || get_user(bstime->tv_nsec, &bstime32->tv_nsec)) diff --git a/fs/xfs/xfs_ioctl32.h b/fs/xfs/xfs_ioctl32.h index 8c7743cd490e..053de7d894cd 100644 --- a/fs/xfs/xfs_ioctl32.h +++ b/fs/xfs/xfs_ioctl32.h @@ -32,7 +32,7 @@ #endif typedef struct compat_xfs_bstime { - compat_time_t tv_sec; /* seconds */ + old_time32_t tv_sec; /* seconds */ __s32 tv_nsec; /* and nanoseconds */ } compat_xfs_bstime_t; From patchwork Fri Dec 13 20:53: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: 181599 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1147590ile; Fri, 13 Dec 2019 12:57:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzUoOGs6rVS3YTM9iixgRatR5le2TMCJ9dje+vI3JoN8RilaXpyNScPagYbeyWtKgLF91xo X-Received: by 2002:a9d:7c97:: with SMTP id q23mr77257otn.253.1576270679411; Fri, 13 Dec 2019 12:57:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270679; cv=none; d=google.com; s=arc-20160816; b=DwkYm8T1cloV+l6CZtzlAp9t1Mc7VwpJf6G64O6HCa/h+ezkoFb+n8GrWYrGJQwOms MveIxJfpJQaBN319eSPEhu9Gm//fKyXCh6HE+h5yTPyDoV+Xp627xdmFmBvBamL9cbCM 2rBstbEqvVUb5D4+Ge4muEYK9nUL5Z8lQzT+7t04i8dJ2OLgSiTQIMGJ+6DoK7DGJCre LTCq1MG0BRqUgSO9DcMIFq3fGWg2mnw6tnITDdvH+vlYyoSeofGJ2ymO5eIkONlaBfvl 2MjnQtoQjyqMYL2Zpdq7YjXWKS9RwDKW3mLtxlJn/vyUbuwG/JVyxgd41ozPgnnuHK20 wOZg== 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=k1AvN79hsh0wo1gmD9xBQusvZq2l0Xt6ExNALbEvT7k=; b=a2pRTXjFrZa6OlJIv0WGtxoOCIjnCQrdHKMDEQW60CQsf9SESgVeLo8XcOPdSR0HsV +RcA9KKqOLcAkycp6+/hRVYq3WFuvUbbhyxX/cvbDx8qFTy5iUu0B+tn+ySwcDcCbFMX a5jYWln1tH8Px1SoWdqRBjhz4QaaCmSj9Ip885PgowRA6PlaByXNorYbsQtKpCjFGDf4 XanyifVCsit6HVHZ07Hy6qwzxUHbM4laPWcNy/IT/i+CJWevRt1bX6j3FFcJbEUSEStT YKy6Gidn2cu+f9XFCtblTPkRgcOw/8Yq5xVAKta8fyF3O6TweEUqW72hMkmnqrASgXfv 4TfA== 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 a20si6036052otf.271.2019.12.13.12.57.59; Fri, 13 Dec 2019 12:57:59 -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 S1726856AbfLMU56 (ORCPT + 27 others); Fri, 13 Dec 2019 15:57:58 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:56003 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfLMU55 (ORCPT ); Fri, 13 Dec 2019 15:57:57 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1N9dg5-1hcRf53jM5-015a8l; Fri, 13 Dec 2019 21:57:46 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "Darrick J. Wong" , linux-xfs@vger.kernel.org Cc: Arnd Bergmann , Brian Foster , Dave Chinner , Allison Collins , Jan Kara , Eric Sandeen Subject: [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time Date: Fri, 13 Dec 2019 21:53:48 +0100 Message-Id: <20191213205417.3871055-11-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:+OC98lqsRIacY7Fo8hffNaEguwEx5BrW1ehoyzc3XQFB5ZHNiyH 3YX603rEPTrkOQExfMO9QXAGFroF+FD93OMx9FVC6EZty09STF3GnlQELmGO576vt5HzmMn X5re2BzBcKgFmWs4Z1qDbbqpMGHnWYZCouGOGdR3XUvGTqVJihZQ7bnJ/2nvsy1qXT1bBNT LbByJ8SMK3jY0wg9jfTVA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:hyZOFL3Pdhc=:c8WEjei9ibUrYRg7I5nOOT uV2U+LutYN//sc6CK3IG/2yqD9u5+kPxqEpfyfGI5AnPSM42vSXYkcWAmuHZNl3qkpHZfBfi5 jL3Y/aBoYbidXGGJpMF9E4OjvFS+f1i0kfrEk6woVEmJDvyxstAQx0azJUrOpRZ8D5lMEErZY zKTSPj3FmzEE7eIytszzFwKN7qLS0lY4X+6j76qz+q46OloyHeJE0EZy9TiVFErDzyzMt7Rrw DEDRlCQfw9ic8qFrLRqjgIitBCIhLFktVhXGQVtF8Hw4gXZONvO3lF/Ugtfpscc9K3DuEz7NO Tl/TE2WRwqa2ELqxyPYka4nMkdhcQ6XBF1GmkHKtzbStWOLw4Mn6OUpCRasZZ1iArigNbCA39 xvzP7ILLUKggS0iNdk6flDo16UFbFGuN5Owv0f59Jm6ipUZntiBhIm2GjTE0bTPdFq6vasDAk SFTAJT/jZtxnclb1CEN7VFV4ZV81CxAqh/2ISzAhACjF5gE3OTVR0fz5Fil39oMVYA1uEGIT3 HWoPW/SNtQ363sKS75X6AAyU9us76vzNZbZyPj3Hi7BYvXrSdLoOAajFzm7gEYfPWJlQ3GJS5 lriS8hPIMhzMFlAEnAw05o0230kTwVbTLNafzi7NjuGr/2YnwzdVoAJRe3Q+6hxYQx5XcJLYU gHc2QlrcR8ihFfBqSSxgf/5OA9HkYzWL02Ey9ma6puSYTXvA8kqvcCeCKm+Y07/FKPiQdJ6ut ufWZcVA+3+STIzCrybd1pcL1zSIUCpmwFMvwlvCEEKzPw48lb7P48aagOI/F7pG3V2O+b6Z4M TJGaa3pPvY/0B4jk3pyexJfYgefRXzzP9aN7oQZ3CjYDbtfQnBUfJiyByUAHvN1GfXJ4E08fU 3wzrXqTv0isiQ9PrA16w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When building a kernel that disables support for 32-bit time_t system calls, it also makes sense to disable the old xfs_bstat ioctls completely, as they truncate the timestamps to 32-bit values. Any application using these needs to be updated to use the v5 interfaces. Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_ioctl.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 2.20.0 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 7b35d62ede9f..a4a4eed8879c 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -36,6 +36,7 @@ #include "xfs_reflink.h" #include "xfs_ioctl.h" +#include #include #include @@ -617,6 +618,23 @@ xfs_fsinumbers_fmt( return xfs_ibulk_advance(breq, sizeof(struct xfs_inogrp)); } +/* disallow y2038-unsafe ioctls with CONFIG_COMPAT_32BIT_TIME=n */ +static bool xfs_have_compat_bstat_time32(unsigned int cmd) +{ + if (IS_ENABLED(CONFIG_COMPAT_32BIT_TIME)) + return true; + + if (IS_ENABLED(CONFIG_64BIT) && !in_compat_syscall()) + return true; + + if (cmd == XFS_IOC_FSBULKSTAT_SINGLE || + cmd == XFS_IOC_FSBULKSTAT || + cmd == XFS_IOC_SWAPEXT) + return false; + + return true; +} + STATIC int xfs_ioc_fsbulkstat( xfs_mount_t *mp, @@ -637,6 +655,9 @@ xfs_ioc_fsbulkstat( if (!capable(CAP_SYS_ADMIN)) return -EPERM; + if (!xfs_have_compat_bstat_time32(cmd)) + return -EINVAL; + if (XFS_FORCED_SHUTDOWN(mp)) return -EIO; @@ -1815,6 +1836,11 @@ xfs_ioc_swapext( struct fd f, tmp; int error = 0; + if (xfs_have_compat_bstat_time32(XFS_IOC_SWAPEXT)) { + error = -EINVAL; + goto out; + } + /* Pull information for the target fd */ f = fdget((int)sxp->sx_fdtarget); if (!f.file) { From patchwork Fri Dec 13 20:53: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: 181600 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1147854ile; Fri, 13 Dec 2019 12:58:17 -0800 (PST) X-Google-Smtp-Source: APXvYqylZF8HI7D0BQ4DokCLiD5pE5LMWzyKB+tJfizU6PMojqpWwADmX9gQjsczwv6RbHmgeAF0 X-Received: by 2002:a9d:7393:: with SMTP id j19mr16259499otk.336.1576270697023; Fri, 13 Dec 2019 12:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270697; cv=none; d=google.com; s=arc-20160816; b=W3bI41NumMSA5CZi/hJB2p2n6Nu/PU9CKBqO2KbhVVnCqyHnrgghDG4hI5lwI4OwXy YAHSPNHacVLlpmPsejy7fItzm+/M9DxKDugwNRhb9IKFBXmnsO0Tgt+UyMAvlXtPge9i HYFepFkeafI34XldWvfYAEk4Ewioqo4NgvB9w5rT4kZqCspZphxwvXO4XkQ+hb2TKNVL LtTBILDv3tQjXNmouWjMrr57tWB7n1G+bodaYXOVvsypusrX5v0+xdi0Y7jC93ZVdCdD n5d0+hhx+OsFam9eHA70RpxGqshNJ1X5LIcSQ+cTUuacyLG63RkOCinaF5QsDVI3yqXF vpjA== 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=1PhR0ni29aq78CDmRCvX3C94ZNWUgUXdPA0E00Mkj84=; b=vgWhJCeOyPqxXaF1IH53li/03ncIo2Ekt2TZwUGuGYHOdje3tWbzVHMoCuUR8/u+aT BqD6BVESnXuWq/OLcoUID8dYK3B4QR0UcWHRxnT3s0S7J6aGwapHytjDoRvCZzFuHQej a9XDF9ZCSMpDzI0lxWEi0ojmK8LRBNhgB/qoh2HMhMZn54Y5Z2aWyprOR+AvA1syf0l0 IZb+hopghfZD5sXeD+HeAbCrKUTcsWn3MNfufg3JjsVptK9kd6yDD8imjzB+AuvdgKU1 JLanahb5iI86TuRIT40m7RdeRRajcu+nYFQgE9xekuCCONjSo5IXK+lfevjT4cerCRQa QhVw== 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 a20si6036052otf.271.2019.12.13.12.58.16; Fri, 13 Dec 2019 12:58:17 -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 S1726869AbfLMU6P (ORCPT + 27 others); Fri, 13 Dec 2019 15:58:15 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:60083 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726494AbfLMU6O (ORCPT ); Fri, 13 Dec 2019 15:58:14 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M89bP-1iacoR0uTj-005GHx; Fri, 13 Dec 2019 21:58:04 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "Darrick J. Wong" , linux-xfs@vger.kernel.org Cc: Arnd Bergmann , Brian Foster , Carlos Maiolino , Pavel Reichl , Eric Sandeen , Dave Chinner , Allison Collins , Jan Kara Subject: [PATCH v2 21/24] xfs: quota: move to time64_t interfaces Date: Fri, 13 Dec 2019 21:53:49 +0100 Message-Id: <20191213205417.3871055-12-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:U4OoSyJcMxWrLz56NTLy5TvcMiZnlFrF1R3kAshvAlEbSRCOzeC MU+a+kgOurK/EF2WxWRPMR623nA1fdKR5uRZ5zKbNPf7Q2ifioCKn5m71y7W41kzptK+bmW 9TOOEK3FNdMOUOQoRUe5MnmmUq4cS3xgQeGYFPjj5jUUq3spY9G9co13nAzhAlTt8J/ZDfO +dqdMz7x2VQcU+LqrJVNQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:4lyDylcgSX0=:F5ZQkV9kT770JxgnJn/cL8 evBqGVlSOOHU9YaF40rxkzMeuVOWdyUbeluOGJJoi27Gtec8k8wXepwcwF2X+kQ/bGHRH+J8j PjjDXCcTk2Hty4XzJOPpv7Fv0xgqAP+4gQfP8IdGfq2OuJ/OyARMKjaCfYMhmYLIP3wrg6ccW gtiugyTF6LhkR33EtG6hVSDPgEXi/exbCoyrKa6ShVgnIi/JlRRJBYPgj16sjAMO/OXbkvY6u Xps2P8/JfVrKNZbEiZlLVALGFNqcrUdGKMOUOT571zbbP7E62dCsyD02WJMx8t0JydYxsC/Ou VtgaSRolPluzw+f7YnHCpjtW4QxfSH60A9mLCFjtEg0SQiDmUxREbHg3t7FVMBSGkktjffPAz LFgTgjqOoYjMEHC5hNqhHp1HmEJvIuXDpcLpPu5VD8VnYLDl7YSM71H6pZm4oL7VrAFpgcD0s l9qvZ/Jx0kmcY97rs/JGUZQXE6C5exrGmn2EZLLXyBZ+AKj83tgyN8NZY7olersMN9gPyeafi n1EpZh7UBE+d/XXv5ZvG7rqLqCAE9Sk2q6rik8uvPQ6DqP6aEvyQ50sA6CgFKwP2p3pdJelUO 5rFSAbi9xXwOqG0ZwWf++sNzNgbH3uiPbJ0poN26J4mz3BZmaKNVv3nY9UFqUCH5J8y37HHrC RFD0VmbxowJHo/BR9zbH3SBtYyP0ODVTvILY5ibLHYZMMkktaI+DZXL0LHXVbczPyIs3cUCx5 dgU73Z+qHw36dXcT3e6TEf9S9ASK7H4SEglU5STCth0eRVfRvGBiyf6GteFPF2suKIchlxBo9 5bBLjgE/fCM3JhJUtx7QoCvNKcxyA7urx4LcaHNsEjy7ZKwk5V21PMatuptaWTElQOF7utsKd sdIkxulCikM8Z1R+3ZYg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a preparation for removing the 32-bit time_t type and all associated interfaces, change xfs to use time64_t and ktime_get_real_seconds() for the quota housekeeping. Signed-off-by: Arnd Bergmann --- fs/xfs/xfs_dquot.c | 6 +++--- fs/xfs/xfs_qm.h | 6 +++--- fs/xfs/xfs_quotaops.c | 6 +++--- fs/xfs/xfs_trans_dquot.c | 8 +++++--- 4 files changed, 14 insertions(+), 12 deletions(-) -- 2.20.0 Reviewed-by: Darrick J. Wong diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 2bff21ca9d78..9cfd3209f52b 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -137,7 +137,7 @@ xfs_qm_adjust_dqtimers( (d->d_blk_hardlimit && (be64_to_cpu(d->d_bcount) > be64_to_cpu(d->d_blk_hardlimit)))) { - d->d_btimer = cpu_to_be32(get_seconds() + + d->d_btimer = cpu_to_be32(ktime_get_real_seconds() + mp->m_quotainfo->qi_btimelimit); } else { d->d_bwarns = 0; @@ -160,7 +160,7 @@ xfs_qm_adjust_dqtimers( (d->d_ino_hardlimit && (be64_to_cpu(d->d_icount) > be64_to_cpu(d->d_ino_hardlimit)))) { - d->d_itimer = cpu_to_be32(get_seconds() + + d->d_itimer = cpu_to_be32(ktime_get_real_seconds() + mp->m_quotainfo->qi_itimelimit); } else { d->d_iwarns = 0; @@ -183,7 +183,7 @@ xfs_qm_adjust_dqtimers( (d->d_rtb_hardlimit && (be64_to_cpu(d->d_rtbcount) > be64_to_cpu(d->d_rtb_hardlimit)))) { - d->d_rtbtimer = cpu_to_be32(get_seconds() + + d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() + mp->m_quotainfo->qi_rtbtimelimit); } else { d->d_rtbwarns = 0; diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h index 7823af39008b..4e57edca8bce 100644 --- a/fs/xfs/xfs_qm.h +++ b/fs/xfs/xfs_qm.h @@ -64,9 +64,9 @@ struct xfs_quotainfo { struct xfs_inode *qi_pquotaip; /* project quota inode */ struct list_lru qi_lru; int qi_dquots; - time_t qi_btimelimit; /* limit for blks timer */ - time_t qi_itimelimit; /* limit for inodes timer */ - time_t qi_rtbtimelimit;/* limit for rt blks timer */ + time64_t qi_btimelimit; /* limit for blks timer */ + time64_t qi_itimelimit; /* limit for inodes timer */ + time64_t qi_rtbtimelimit;/* limit for rt blks timer */ xfs_qwarncnt_t qi_bwarnlimit; /* limit for blks warnings */ xfs_qwarncnt_t qi_iwarnlimit; /* limit for inodes warnings */ xfs_qwarncnt_t qi_rtbwarnlimit;/* limit for rt blks warnings */ diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c index c7de17deeae6..38669e827206 100644 --- a/fs/xfs/xfs_quotaops.c +++ b/fs/xfs/xfs_quotaops.c @@ -37,9 +37,9 @@ xfs_qm_fill_state( tstate->flags |= QCI_SYSFILE; tstate->blocks = ip->i_d.di_nblocks; tstate->nextents = ip->i_d.di_nextents; - tstate->spc_timelimit = q->qi_btimelimit; - tstate->ino_timelimit = q->qi_itimelimit; - tstate->rt_spc_timelimit = q->qi_rtbtimelimit; + tstate->spc_timelimit = (u32)q->qi_btimelimit; + tstate->ino_timelimit = (u32)q->qi_itimelimit; + tstate->rt_spc_timelimit = (u32)q->qi_rtbtimelimit; tstate->spc_warnlimit = q->qi_bwarnlimit; tstate->ino_warnlimit = q->qi_iwarnlimit; tstate->rt_spc_warnlimit = q->qi_rtbwarnlimit; diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index a6fe2d8dc40f..d1b9869bc5fa 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -580,7 +580,7 @@ xfs_trans_dqresv( { xfs_qcnt_t hardlimit; xfs_qcnt_t softlimit; - time_t timer; + time64_t timer; xfs_qwarncnt_t warns; xfs_qwarncnt_t warnlimit; xfs_qcnt_t total_count; @@ -635,7 +635,8 @@ xfs_trans_dqresv( goto error_return; } if (softlimit && total_count > softlimit) { - if ((timer != 0 && get_seconds() > timer) || + if ((timer != 0 && + ktime_get_real_seconds() > timer) || (warns != 0 && warns >= warnlimit)) { xfs_quota_warn(mp, dqp, QUOTA_NL_BSOFTLONGWARN); @@ -662,7 +663,8 @@ xfs_trans_dqresv( goto error_return; } if (softlimit && total_count > softlimit) { - if ((timer != 0 && get_seconds() > timer) || + if ((timer != 0 && + ktime_get_real_seconds() > timer) || (warns != 0 && warns >= warnlimit)) { xfs_quota_warn(mp, dqp, QUOTA_NL_ISOFTLONGWARN); From patchwork Fri Dec 13 20:53: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: 181601 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1148200ile; Fri, 13 Dec 2019 12:58:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzVZCe/AkMZ+TUL22tVMLa34aDiAVJN3fTNI+lrCQLX2qtwZiRyKr0wxZuzeyhclBTLvSI8 X-Received: by 2002:a05:6830:611:: with SMTP id w17mr16918105oti.191.1576270723090; Fri, 13 Dec 2019 12:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270723; cv=none; d=google.com; s=arc-20160816; b=ZCNh+F7i1gXdTVPdw9yPRt5c5zhhxaK1aE9KESgOv366YgyqU9RiYRJ0oKInkvJR6Y a9ZVqBe/Cs3Yf0U3m0B51o0O4V+bj9TKNaHcQRi5Wr9jWE+hBGfhiPd0LIs+IlpwoHF2 gE3rozHEKm4IlOSqaXQYCCZCAVMcMrGltk/h9g4+u9+mSAo6aIJ16XEk3om6y9GjR/iJ VmGOQS9RSnj+CT7WOyDmp+DnZyjOcnpu7Bhca7IHlWQebQdW4JRPsOnbWJztXh8RMj1y UGCsLEIx5Bn0qvfpPaEuzSWfcK2o0Mv9LERPocG/yBizigNxjt6PtysidGuLRUkPR+gS VR9Q== 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=E6UrRJPbJHLJngjocCZzRepZeoINa62e+25XCLVBjOA=; b=fULNssv5w+zzosrjyJ0sfet9uYxwuUasDz26BPgRvdktIRjL531ima08CCF73gTVh6 b1NulIiPo05Zs2uelTHIJ+WS/FIyrSDfP0Cta9jpWBGRirm7edcD4FKVCTxR6MdC7DEJ KjZVDzgcPoCzC8y77vBGsgy7bZWYAT31cfn2QKjWAefMzR9U9k/HZeAuRxduoOY2TdDz 2+kOXpc1K+B4zZPHZ1f4Ys9OtEL41xodF/utFsp09TOBp4huXoaNNdzo0JtAR+hnTER7 w5NsV+Dc2b6aV/9vJ7/+ml27v9/6Q1VF6Xc26cKwrcn2ENIbZZsaFljfHs3DyGjV0tpL vrEQ== 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 t189si5768945oie.13.2019.12.13.12.58.42; Fri, 13 Dec 2019 12:58:43 -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 S1726760AbfLMU6l (ORCPT + 27 others); Fri, 13 Dec 2019 15:58:41 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:58183 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfLMU6l (ORCPT ); Fri, 13 Dec 2019 15:58:41 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MbS0X-1i8S0J3tFZ-00bs55; Fri, 13 Dec 2019 21:58:19 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, John Stultz , Thomas Gleixner Cc: Arnd Bergmann , Stephen Boyd , Li RongQing , Zhang Yu , Pablo Neira Ayuso , Deepa Dinamani , Christian Brauner , Dmitry Safonov <0x7f454c46@gmail.com>, zhengbin Subject: [PATCH v2 22/24] y2038: remove obsolete jiffies conversion functions Date: Fri, 13 Dec 2019 21:53:50 +0100 Message-Id: <20191213205417.3871055-13-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:+a7egnHYu/Vs4tGonIvWpddWPqQ3G3Wrw3UoOy1c8w4nWtkSLIH WP2j0kouEaxCIxmbWZSzvBL11f1KKh3/hew5IawQz0XOCrQ+gKizADA7n/VPFRd7zTV1smC k00875l342HVLxFmg7rrE6XRu7CNsuFPtLzP6FrKoEmYKUCt98BHJerR6wFhBdm7/cPzyKx byCtsDXIHe1CvT7R5U5vQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:FkIUgD1sr+w=:QqhdATVnkuEIRaTgHU5R3C 8JX3YcqaA/s08qA+8JMS+qQUnItFmEfkGxSPHCUTLLwlAFupj8E84/HhYAcw8v2t4HyfFW5Hd 3MQhV20eSbXQAxcfAPTC8qCnnKKpPsfTgaKA1o6VKvx4zIqiYJCpraES3tZY3r3jYQk9D5P1e Pw5F4LryugGgsLY+8wn9lcLRyXcOqmVfEdtTYAIka/HiEqUfRxwWGYRN1tR4cBh58PE22EGGO MoC0SnGtmSJydlAb+2F3upmMAqC8icW9HCNWn2Fu5HsfWSsaCV8tfqPC1X5Ou5PnZbGbwPt2S kNt3uw2hJwJbQjF+xOiS7FAudO8qj6K3FPIe0DtpNCjm0mJdDthrwXL5MqER2m51d5iDP4s1y DN6gi1U/9Xvti3wjsFcU+W2aqGphQCWaYOCYcAvDFyx8frrzOIh80iKwTXQZpwvJ19JuknobV b8Z7RxIVIZPLkjRrsfUEp93zrnvScXj9cz6Gj2flRSdG9/uM1pit9V8J9Wlu7S+aHjSeSm+6I ssX7OgleqxE6weQytJyWjN/XI0YdIIiUn4ZXTiwbgzlN3Nhxv60A9HwXolMdjcelo4NyiOX7e nr2rLrzpVYPKUq1x/DDEuzRVDx5iw4qs2ogq+agjVaNn91aQ4L2CnyjRqVo4a7CGb7DttqDNB e8RiLkP3xvV7+6JOviizoG2Lc8hj7X4EpV2eRd0ScYnkabXCr+yAQLdjTIEaGLDJN09rrXqQC Os5oW+oYwNs+NXa9Gn2wZ41I2Kwnp595vJTbaUDToapua3e8BDV0XLhtBYkS1+8yyVoawOsBr T36Sij30o6PfQUh0rKwnv1syW3iJpBhEGLw8OZMlwACYH4Af1QP7/+TUhOzqJNfQSOFsbGdCq pfrnDEOrRLxjz0wuNXYQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the last user of timespec_to_jiffies() is gone, these can just be removed, everything else is using ktime_t or timespec64 already. Signed-off-by: Arnd Bergmann --- include/linux/jiffies.h | 20 -------------- kernel/time/time.c | 58 ++++------------------------------------- 2 files changed, 5 insertions(+), 73 deletions(-) -- 2.20.0 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 1b6d31da7cbc..e3279ef24d28 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -422,26 +422,6 @@ static __always_inline unsigned long usecs_to_jiffies(const unsigned int u) extern unsigned long timespec64_to_jiffies(const struct timespec64 *value); extern void jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value); -static inline unsigned long timespec_to_jiffies(const struct timespec *value) -{ - struct timespec64 ts = timespec_to_timespec64(*value); - - return timespec64_to_jiffies(&ts); -} - -static inline void jiffies_to_timespec(const unsigned long jiffies, - struct timespec *value) -{ - struct timespec64 ts; - - jiffies_to_timespec64(jiffies, &ts); - *value = timespec64_to_timespec(ts); -} - -extern unsigned long timeval_to_jiffies(const struct timeval *value); -extern void jiffies_to_timeval(const unsigned long jiffies, - struct timeval *value); - extern clock_t jiffies_to_clock_t(unsigned long x); static inline clock_t jiffies_delta_to_clock_t(long delta) { diff --git a/kernel/time/time.c b/kernel/time/time.c index 704ccd9451b0..cdd7386115ff 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -626,10 +626,12 @@ EXPORT_SYMBOL(__usecs_to_jiffies); * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec * value to a scaled second value. */ -static unsigned long -__timespec64_to_jiffies(u64 sec, long nsec) + +unsigned long +timespec64_to_jiffies(const struct timespec64 *value) { - nsec = nsec + TICK_NSEC - 1; + u64 sec = value->tv_sec; + long nsec = value->tv_nsec + TICK_NSEC - 1; if (sec >= MAX_SEC_IN_JIFFIES){ sec = MAX_SEC_IN_JIFFIES; @@ -640,18 +642,6 @@ __timespec64_to_jiffies(u64 sec, long nsec) (NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC; } - -static unsigned long -__timespec_to_jiffies(unsigned long sec, long nsec) -{ - return __timespec64_to_jiffies((u64)sec, nsec); -} - -unsigned long -timespec64_to_jiffies(const struct timespec64 *value) -{ - return __timespec64_to_jiffies(value->tv_sec, value->tv_nsec); -} EXPORT_SYMBOL(timespec64_to_jiffies); void @@ -668,44 +658,6 @@ jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value) } EXPORT_SYMBOL(jiffies_to_timespec64); -/* - * We could use a similar algorithm to timespec_to_jiffies (with a - * different multiplier for usec instead of nsec). But this has a - * problem with rounding: we can't exactly add TICK_NSEC - 1 to the - * usec value, since it's not necessarily integral. - * - * We could instead round in the intermediate scaled representation - * (i.e. in units of 1/2^(large scale) jiffies) but that's also - * perilous: the scaling introduces a small positive error, which - * combined with a division-rounding-upward (i.e. adding 2^(scale) - 1 - * units to the intermediate before shifting) leads to accidental - * overflow and overestimates. - * - * At the cost of one additional multiplication by a constant, just - * use the timespec implementation. - */ -unsigned long -timeval_to_jiffies(const struct timeval *value) -{ - return __timespec_to_jiffies(value->tv_sec, - value->tv_usec * NSEC_PER_USEC); -} -EXPORT_SYMBOL(timeval_to_jiffies); - -void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value) -{ - /* - * Convert jiffies to nanoseconds and separate with - * one divide. - */ - u32 rem; - - value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, - NSEC_PER_SEC, &rem); - value->tv_usec = rem / NSEC_PER_USEC; -} -EXPORT_SYMBOL(jiffies_to_timeval); - /* * Convert jiffies/jiffies_64 to clock_t and back. */ From patchwork Fri Dec 13 20:53:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181602 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1148438ile; Fri, 13 Dec 2019 12:59:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzdmVvN1Hq+I6N0VR2WGkJpvI0/oqT3g1ZqCRLKDrqtvLTOvzGOAVczRPfY/yVqZaCHM+wO X-Received: by 2002:a9d:192f:: with SMTP id j47mr17367336ota.230.1576270743193; Fri, 13 Dec 2019 12:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270743; cv=none; d=google.com; s=arc-20160816; b=ahGz3y4UgGPRR5Dh/EUQpDoVgkvHe022A2gY7baDs6kurOXL0hl9Mcg1US7Q/OLlR7 aVtyAnh6P2QajezMeMI1ryDkOO5+u52yh/nAJkKG0oaVi9N396c5jQIOe556KO4CKevh HJjtj1PvHWBNAZs3B0rbjykRincrWxUts6YugnXDoMF8rq8/RBOuDY8btRjG28lbexxZ cD9IC+6vxZ/IjRyOS8bm5zc4bqsfAIB7AtHZK0jadE9B1JsI3rY/++CM7mHEh7L66KY/ yyuvQiChNxCwXOcfoRlfMIeSFlu4uyRTjaV8W7Zp0uBGkpbZDzkXdx161qedl+OMeyME ttJw== 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=/zewsCciA1vIrfaJY0i29S2WloP01HNfc/ruPLC/5fE=; b=HwiQtO4o0dmiCtIIWuN7Y4Bno+ez0dhoMRamXPKs/WUHqWvkpX0xtMw1iHe+mqv8UO WYBSSu+kBJhKIKNkyxkCMSE9j4aKMe6FI81o9e0sNFeVMIt8oYY/1T+Amv/GFmZIRTGe 4Z+C794VMuDG8vStmaifSLc2GHOTO7axb6kWU31sOkjGVZDE23DsBGnuW9+o1hoBUVzJ kbr9SxZubcSD2vkpoghG7gwpXGu2aLioF3L0tlKVLs1J0OaxQ/2WKUKV1Vtq4M49MVFG eNA9YK1Pl0NZ7QSTzTvPEPhP7n9baZMbPpwL9k70XLDAECCEY+PhriHVWJx4YGjBsimw 0wvg== 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 t189si5768945oie.13.2019.12.13.12.59.02; Fri, 13 Dec 2019 12:59: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 S1726783AbfLMU7B (ORCPT + 27 others); Fri, 13 Dec 2019 15:59:01 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:59065 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfLMU7B (ORCPT ); Fri, 13 Dec 2019 15:59:01 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MsZBb-1hqEMw1io7-00u5gf; Fri, 13 Dec 2019 21:58:37 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Thomas Gleixner Cc: Arnd Bergmann , David Howells , Al Viro , Christian Brauner , Heiko Carstens , Jens Axboe , Deepa Dinamani , "David S. Miller" , Frederic Weisbecker , "Peter Zijlstra (Intel)" , Anna-Maria Gleixner , linux-api@vger.kernel.org Subject: [PATCH v2 23/24] y2038: rename itimerval to __kernel_old_itimerval Date: Fri, 13 Dec 2019 21:53:51 +0100 Message-Id: <20191213205417.3871055-14-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:TqEgrqVYKBUXuLUugtmSXz5Jp0XWvxFbL1EF+DOHK3fjEd6Fk++ cRocth6aVdmtqKW7gyyAItEa53K8m1Gj+h/gCmRCJQ9zcX1JYTHfDh/mFaEreuJDcAKCAZT /V9BL4c/fgg/VV2hxw/J3nff8wTDToWlulMn4wWP2yM+Dmfi6/N/FbZBS6ov0rwtgjxVJtk c8qGaN7z75Bvc1ShlL9ZA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:+nujEEc8rtU=:gcuncyiULxaR/b5DAOMBO4 oR6U8INsRH3MZPCNpISnel4mn+Th5CEnjPhMuYbhPA4rqvNI08Q1scKBLZNct5p3rcFjDwIbz UQoWffQ5d+Vj2Jn8UKlSYJQXU52k2xvazBuG4p0PjLQoH4j0q6O/LJ205v5nPBWeoz8rj7kI8 HqaAhvKSpkQiSwJoZUjs9m3r4zxOXPmS1EkaaUwWgeEH0OJLXMXs1+u0f4lUPqkCGws7ijvic 3ApO1TPXrmsIno6Q79YNWvQ1fCrQiJlRC0uXjPfCiDwGY5eTqkPfT18zvl62gsf/Np4eAiidp IGZIE9Lhfthids1bllMSSx8JVmG+LSI/HCAQ4dKeZBqJ8ttA8rcfvMQVPkogWclTTyxGldeLZ rnd2wX0yS9MZ+jAUnbFJ/LcIpdx3w72hz666SrW9hMBDOHLcscDx34uZKFsoWDCkTifyCjl7z AypDolytB3UPMJQAnj9tFLm5K+dp0srYZaXb7GwUVp6i8MpI210/zVJFOhq5aPOfWkCvjRHNb rZPp4nxsnppchEXbWmFkSdPqGCbEEoVljg7H6Ep2RB6ATD5Hx2iSRTRiUguyYgSmAgzfsJsCU cRE6ctY6cBBcpuOw7F5+k2og4/8z1HI5a/aM5l7Xd4kEuGkqIC7Kaswp7zS0wixJx41Jk3ole SRIW0zvRsp17fOmCXbHpUT+yik5W7XTAZd4JlNg+3cSmlIJLGyomTzFN/UGD0uvocGaO165rp qhOoRT5Vq6DsCmyglMiyfsTiwYjF83UA0eGSzww+ca9Tpqs9epkhVvRNhvCAmu2Ce+9EsSHwc SdUS4EMmf/Sbp/RB91XuBjZ/nSkpgqUyVRZIbhlf2rU/cClbeahuKr/QL3qvA45DahX1lHSjI g8WIW7F2WBR4mn4nyMTg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Take the renaming of timeval and timespec one level further, also renaming itimerval to __kernel_old_itimerval, to avoid namespace conflicts with the user-space structure that may use 64-bit time_t members. Signed-off-by: Arnd Bergmann --- include/linux/syscalls.h | 9 ++++----- include/uapi/linux/time_types.h | 5 +++++ kernel/time/itimer.c | 18 +++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) -- 2.20.0 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index d0391cc2dae9..27245fec2a8a 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -16,8 +16,7 @@ struct inode; struct iocb; struct io_event; struct iovec; -struct itimerspec; -struct itimerval; +struct __kernel_old_itimerval; struct kexec_segment; struct linux_dirent; struct linux_dirent64; @@ -591,10 +590,10 @@ asmlinkage long sys_nanosleep_time32(struct old_timespec32 __user *rqtp, struct old_timespec32 __user *rmtp); /* kernel/itimer.c */ -asmlinkage long sys_getitimer(int which, struct itimerval __user *value); +asmlinkage long sys_getitimer(int which, struct __kernel_old_itimerval __user *value); asmlinkage long sys_setitimer(int which, - struct itimerval __user *value, - struct itimerval __user *ovalue); + struct __kernel_old_itimerval __user *value, + struct __kernel_old_itimerval __user *ovalue); /* kernel/kexec.c */ asmlinkage long sys_kexec_load(unsigned long entry, unsigned long nr_segments, diff --git a/include/uapi/linux/time_types.h b/include/uapi/linux/time_types.h index 074e391d73a1..bcc0002115d3 100644 --- a/include/uapi/linux/time_types.h +++ b/include/uapi/linux/time_types.h @@ -33,6 +33,11 @@ struct __kernel_old_timespec { long tv_nsec; /* nanoseconds */ }; +struct __kernel_old_itimerval { + struct __kernel_old_timeval it_interval;/* timer interval */ + struct __kernel_old_timeval it_value; /* current value */ +}; + struct __kernel_sock_timeval { __s64 tv_sec; __s64 tv_usec; diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c index 9e59c9ea92aa..ca4e6d57d68b 100644 --- a/kernel/time/itimer.c +++ b/kernel/time/itimer.c @@ -97,20 +97,20 @@ static int do_getitimer(int which, struct itimerspec64 *value) return 0; } -static int put_itimerval(struct itimerval __user *o, +static int put_itimerval(struct __kernel_old_itimerval __user *o, const struct itimerspec64 *i) { - struct itimerval v; + struct __kernel_old_itimerval v; v.it_interval.tv_sec = i->it_interval.tv_sec; v.it_interval.tv_usec = i->it_interval.tv_nsec / NSEC_PER_USEC; v.it_value.tv_sec = i->it_value.tv_sec; v.it_value.tv_usec = i->it_value.tv_nsec / NSEC_PER_USEC; - return copy_to_user(o, &v, sizeof(struct itimerval)) ? -EFAULT : 0; + return copy_to_user(o, &v, sizeof(struct __kernel_old_itimerval)) ? -EFAULT : 0; } -SYSCALL_DEFINE2(getitimer, int, which, struct itimerval __user *, value) +SYSCALL_DEFINE2(getitimer, int, which, struct __kernel_old_itimerval __user *, value) { struct itimerspec64 get_buffer; int error = do_getitimer(which, &get_buffer); @@ -314,11 +314,11 @@ SYSCALL_DEFINE1(alarm, unsigned int, seconds) #endif -static int get_itimerval(struct itimerspec64 *o, const struct itimerval __user *i) +static int get_itimerval(struct itimerspec64 *o, const struct __kernel_old_itimerval __user *i) { - struct itimerval v; + struct __kernel_old_itimerval v; - if (copy_from_user(&v, i, sizeof(struct itimerval))) + if (copy_from_user(&v, i, sizeof(struct __kernel_old_itimerval))) return -EFAULT; /* Validate the timevals in value. */ @@ -333,8 +333,8 @@ static int get_itimerval(struct itimerspec64 *o, const struct itimerval __user * return 0; } -SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value, - struct itimerval __user *, ovalue) +SYSCALL_DEFINE3(setitimer, int, which, struct __kernel_old_itimerval __user *, value, + struct __kernel_old_itimerval __user *, ovalue) { struct itimerspec64 set_buffer, get_buffer; int error; From patchwork Fri Dec 13 20:53:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 181603 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1148661ile; Fri, 13 Dec 2019 12:59:19 -0800 (PST) X-Google-Smtp-Source: APXvYqx6whkPy7apkPPzO48EwFB4RR1+wBuC26NYP9mmoUsLlsQXbFDDUOpM/H0vOZVEAi7ZDZ4v X-Received: by 2002:a05:6830:128e:: with SMTP id z14mr16179000otp.184.1576270759178; Fri, 13 Dec 2019 12:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576270759; cv=none; d=google.com; s=arc-20160816; b=x9GUF0hjaPR/pXt6hRG+qb2s4HyclqXHWVyO/m2keYaPMluLrfAgnFtRCf3QTHcuTj W5NC8eSJF6PZDSGIGKS+quHa8AvSKRsU7GXEwlKCSwadcy+zKqZXdo93s8VfQAYY10sH En3fZKXQS2zKmvDS/V2YV9j0V08ntd1rI8CW63XcSfpEioAJ7+v8DL/4X4VS7crspRgd z2dq+NwDlZcrQi93dUWhLlhm/tBx/DHRH7rvNYkRNJrTp3nW21ao6LZqXZluWQ5l+LQf 5D2S/aEXNw8FCAwywUxuVrawRh0kto5XZo+lZjL2S29Z+f4A/1TLQqRkUTnIShDvg4Ut Btsw== 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=lqFJSoKOOCpOR/dHKdqW7LOcQwruPPx8GcOnFT2M7ng=; b=udjy5BbBcIAhBYAXzvHpSbc/QEqgSYtrzIFzm/23JpTRnIWNuApskUjAPNeDyuxunk VOk4TlItkh7VgndqcM+HiCHFHbEleGNI2yitXMMCS1SeHR/GKj0YbxhQjvr/9HHVbFhF M1FPWuZluxhZ+Ec2TZb5Nu5euFH9zbxVJLmFscAPxsdcqy0KatzKqP0L1vemp774gt0q wEYinuC1BaMa4+82O8XODmUyO2jZMGrQYIqHZTPk5g6QvS/Wqpdj6aakHXWTqMls1hmd fCqn7CebvFq9xEUTKQofGsoa+yl2IgAekjcBhNxtFBhSV7d+LKjoPeqU04SabJ8YJMLb KDKA== 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 t189si5768945oie.13.2019.12.13.12.59.18; Fri, 13 Dec 2019 12:59:19 -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 S1726828AbfLMU7S (ORCPT + 27 others); Fri, 13 Dec 2019 15:59:18 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:54913 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725937AbfLMU7R (ORCPT ); Fri, 13 Dec 2019 15:59:17 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1N1x6X-1hhwsx45CD-012Isl; Fri, 13 Dec 2019 21:58:47 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, "David S. Miller" , John Stultz , Thomas Gleixner Cc: Arnd Bergmann , Stephen Boyd , Deepa Dinamani , "Eric W. Biederman" , sparclinux@vger.kernel.org Subject: [PATCH v2 24/24] y2038: sparc: remove use of struct timex Date: Fri, 13 Dec 2019 21:53:52 +0100 Message-Id: <20191213205417.3871055-15-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> References: <20191213204936.3643476-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:A7e9/MVVT8BzRCfImaCg9M4jUKmhpwO6crIaNymrEDwlQZeltNw ofdOA22H+2CteR63M/zW7/QJ9xk/xm5IFVcZUCEHHr0oqqYjO2F8BCaw7M36GDA1ouTCTdL XZuuvO73Er8lopAUQzkNngA9tNTZDinleHYow3Tyi+PYH/pzhVVO6ZyLKW/gM0r5NukKCve ucLS2WBHfH5TBH6bwkJlg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:elooNoLl0os=:wJwvhFEbWlK180NJ0akjSc IwQ5iLJjeglZh0liN9JFPCnp0HP2SWD6SDJJ5dLDCQbHYYueqnXerizC/HI9HgURy2945Ym+e PM6PPU3k9wcvKwJVMCS2WBVFEQLDj3xjsKA597uZY2j1O4iNej+KtCgNla7T5EY/cXwJqh8yM tQ8JhxM4qHJezU0J7TI/AFMSDZQ7+LJXkjGLRypSzXhkJCa+XmWXGizlDiOKI7H5Y1cvYlmPr grNp1+Cb7FQeUwPxUofvsVCx7Jr0/ux3M3omtgiUzFqEamULFm2BdG1l1Ee+LRqs3+nuR5Y17 0Es32GbadsSt665oJa61Q56UhPWbZaHCjMjwFBFbx0pQF5PR398evp8kkMCHrBdKXhEZ1moVG IE5yRTE/w6L43ko1QeqCkgYYUB4uEZULTnlLanp5LZyrsRHIDl+/3wvRgDOq62hK+SQT9R7LN o6uZU7XT1ifzYCob6rtsswqrbs7Gxx7h7h6D6mvVXzsYMBaHRseiIxkyQfdnpTvJCNBrJMxow wD7ZVP9yyDTJvzG51Q1Qv38SI2sSrB5TpHzV1eRqeA12bKmO6i0Ck5Ej1kEJrOBDwxea5BZLC H55xBxTLXhAV73IaWkgY7JQWaqYVQ9LSet/er0Pprh8ZkogvymsbLhc5zEYAMZhWFwVSWZ1w/ eXAS9UBJnJVc/Pci+emwQcd8K9slTndz3hYmhZ1xADVoIQ7Iz8wMLRk3+Idz6hpSQg0SIJklt xY2V7xhOOGXlxK904sUolNvMcvCSNNvld7821PQK4/jM/PfsgTlaufqF0BDehwnShertppsWu usrFlmZ4CLcZ9qVJPm1zxMcSX6En/quVRVGCJhFFCL/ZtLaly7rEq7IHU6wkkQ3naAnlgv3gD rSp6ogSKRmbENOUzUb5w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'struct timex' is one of the last users of 'struct timeval' and is only referenced in one place in the kernel any more, to convert the user space timex into the kernel-internal version on sparc64, with a different tv_usec member type. As a preparation for hiding the time_t definition and everything using that in the kernel, change the implementation once more to only convert the timeval member, and then enclose the struct definition in an #ifdef. Signed-off-by: Arnd Bergmann --- arch/sparc/kernel/sys_sparc_64.c | 29 +++++++++++++++-------------- include/uapi/linux/timex.h | 2 ++ 2 files changed, 17 insertions(+), 14 deletions(-) -- 2.20.0 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index 9f41a6f5a032..1c85b0af4dfd 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -548,34 +548,35 @@ SYSCALL_DEFINE2(getdomainname, char __user *, name, int, len) return err; } -SYSCALL_DEFINE1(sparc_adjtimex, struct timex __user *, txc_p) +SYSCALL_DEFINE1(sparc_adjtimex, struct __kernel_timex __user *, txc_p) { - struct timex txc; /* Local copy of parameter */ - struct __kernel_timex *kt = (void *)&txc; + struct __kernel_timex txc; + __kernel_old_timeval *tv = (void *)&txc->time; int ret; /* Copy the user data space into the kernel copy * structure. But bear in mind that the structures * may change */ - if (copy_from_user(&txc, txc_p, sizeof(struct timex))) + if (copy_from_user(&txc, txc_p, sizeof(txc))) return -EFAULT; /* * override for sparc64 specific timeval type: tv_usec * is 32 bit wide instead of 64-bit in __kernel_timex */ - kt->time.tv_usec = txc.time.tv_usec; + kt->time.tv_usec = tv->tv_usec; ret = do_adjtimex(kt); - txc.time.tv_usec = kt->time.tv_usec; + tv->tv_usec = kt->time.tv_usec; - return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; + return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret; } -SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex __user *, txc_p) +SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock, + struct __kernel_timex __user *, txc_p) { - struct timex txc; /* Local copy of parameter */ - struct __kernel_timex *kt = (void *)&txc; + struct __kernel_timex txc; + __kernel_old_timeval *tv = (void *)&txc->time; int ret; if (!IS_ENABLED(CONFIG_POSIX_TIMERS)) { @@ -590,18 +591,18 @@ SYSCALL_DEFINE2(sparc_clock_adjtime, const clockid_t, which_clock,struct timex _ * structure. But bear in mind that the structures * may change */ - if (copy_from_user(&txc, txc_p, sizeof(struct timex))) + if (copy_from_user(&txc, txc_p, sizeof(txc))) return -EFAULT; /* * override for sparc64 specific timeval type: tv_usec * is 32 bit wide instead of 64-bit in __kernel_timex */ - kt->time.tv_usec = txc.time.tv_usec; + kt->time.tv_usec = tv->tv_usec; ret = do_clock_adjtime(which_clock, kt); - txc.time.tv_usec = kt->time.tv_usec; + tv->tv_usec = kt->time.tv_usec; - return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret; + return copy_to_user(txc_p, &txc, sizeof(txc)) ? -EFAULT : ret; } SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, diff --git a/include/uapi/linux/timex.h b/include/uapi/linux/timex.h index 9f517f9010bb..bd627c368d09 100644 --- a/include/uapi/linux/timex.h +++ b/include/uapi/linux/timex.h @@ -57,6 +57,7 @@ #define NTP_API 4 /* NTP API version */ +#ifndef __KERNEL__ /* * syscall interface - used (mainly by NTP daemon) * to discipline kernel clock oscillator @@ -91,6 +92,7 @@ struct timex { int :32; int :32; int :32; int :32; int :32; int :32; int :32; }; +#endif struct __kernel_timex_timeval { __kernel_time64_t tv_sec;