From patchwork Thu Apr 12 14:20:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133285 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp1737045ljb; Thu, 12 Apr 2018 07:20:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/i6hXNIfV4qwL5OqC59wUi6gR+XMJKD+nO91gy7cx5Q25CrGkTSzrTmxHSyDKoze02uRQN X-Received: by 10.99.173.67 with SMTP id y3mr889152pgo.109.1523542854700; Thu, 12 Apr 2018 07:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523542854; cv=none; d=google.com; s=arc-20160816; b=Gqkz1yy03J4gf/ctSTjtYM/AHyIaij5teo0kU4ooFb50DpMHgxG0AOHCqx/Ez+TeaS imNRcDtMO2uZ/iS6Po7yWAfqMjMzAEKRHzUCoF8+eqHyT5P9hk/6rgdICJjQD6/EhGAd gx5TfJB1B4BrUdVmu2akQhj/jXoaIS+G0xYkeTm3QsOEt6BgQ2OZPws/v+8djzBti2Ss JTI71OsPIbdNHlQoGxkOzync0ieNO+o4xgdp4/J54UmVAfO2dIAIBNWMDjpNky+CX+YN ei8gDUCZcjrE6W3roqFRkbQk1L+Eg9Zyn37vFMhhrFlQqF32vSqLd/upbSbcmhYEDwyG HxDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=LlxXVqrPMDk/4DepHDOBPJL20zY2awhXcz0luhv7A1c=; b=hqUCesCXj9MWWrvEEZK3D5OeanxsnOniP4q6GCU2mi9X+Im/8ayCvX7E9QoSw4EY7a C7FredjYz3SfUc2ZwtdiUSOtxauPL2v7ct8pO7xSvNL77vkairtIfoN/AugymcxFbUvq gVEsNTmK2QvzCcX9cKd081ovWWRP0rCyg3upzI1Xol0qXuXDD1lKrUaDEu49ZlHTBAKB NsfXJamMORfztknHZVa0fQw+YgxO0MQgbgOk6qJDvU3pAkJjJd3SV3FOkcUfZ3qShalx AJ890pROirIDvBOkM/1o3cWvS8F4wDyuOy2h9RayNcN1zImqFj0O10xktOnv8rKFEBEb rgIA== 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 s8-v6si3716221plk.550.2018.04.12.07.20.54; Thu, 12 Apr 2018 07:20:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753058AbeDLOUh (ORCPT + 29 others); Thu, 12 Apr 2018 10:20:37 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:35163 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbeDLOUe (ORCPT ); Thu, 12 Apr 2018 10:20:34 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LlnHM-1eXZNw2fKK-00ZSz4; Thu, 12 Apr 2018 16:20:32 +0200 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org Cc: Arnd Bergmann Subject: [PATCH v2 01/13] y2038: asm-generic: extend sysvipc data structures Date: Thu, 12 Apr 2018 16:20:12 +0200 Message-Id: <20180412142024.853892-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180412142024.853892-1-arnd@arndb.de> References: <20180412142024.853892-1-arnd@arndb.de> X-Provags-ID: V03:K1:NKuutRqI7p067JW9fwCYbYyyW5hB2v4KVD1KMZ03pNBoh8uamoZ oKp7k9gCNOABF52XfSSrde5pwVMKeB+KzMJRy3Ms28hKu8oYwFXBVJWv23JHcu2ROlApjIx d/fTyFVeAONjo+WVMtoYiwsjxyYmTMX1TE0TFbyD5Nhynl6I+x2/xpJkMnrF2Dp71w6Y3e2 7psoxVSL71ggwRa+Y5tWw== X-UI-Out-Filterresults: notjunk:1; V01:K0:yLQPo0kZ66Q=:546iYtnoa36G6ymDpAudWk m/+c5+0umWeO73tabDghNOlzoAZBw59aahCWmbzLwzKeZimmPcu2K2ooh3snRXndC/seiIRhm /R9B06OxYD3Re5xAjT1xidC1IlOy6MKVNX38oMCIAaZS168IYXTW4WLJ7T5QHiTZ7yTEJWdwB 8HWwxV1Y/qofYTLK+8rn2ZfWvBpSBC+aTs1D2xuErwE6n8+cS3fRk0vsH8Jar9OMzQWrmD5WW xkg5tMm9pmH6p4r3ja/MMZu45xppHsIhF0Qm6PFTOt9Q/SxDsEiQp5jS7cdG4sni07SaLSR2e Zsrg+Bpcgc/nJmStwooaUEcsqtvo/FII3ho/fQ76iK+yt1nnUen0SqtFAHn07yaWTy1t1qx83 UAa4G45Cq26nlu9L2Ltw252PooerJkBAGSSs8CiI9stQGjH1lwQFpZ8WEyTEEUIVtsOa+KHui t+xO6eQIFnJJZiM1m5Trq6HFod75I3S+xRaiPnJkOZvOdMxBzILK0/UB0uGGzN3hFcsBj1jxU Af8Q3ZN14UyWPFuWyfRNg80+joV+pfKs/Cy0kvMe/y9wB8d3uvkgIKPRrCAQVVl122NY4u+Bf fNEh6vz6hRmCFHXDgdhN68QVFaav7r5Tg/A45TsxcDFb/nNmiwE/+L+xNC/2B0Rp9ti7NPCnZ zCgwzLXH5gER1voJPfHv8efTYCkrj5Me066MzVmu+ZeiKxITJ28nRQzhaZC3bp6ux6OobPI3h iydfL1JAbFkkKjgEpHcyCM5ChooCrBwo472LuA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Most architectures now use the asm-generic copy of the sysvipc data structures (msqid64_ds, semid64_ds, shmid64_ds), which use 32-bit __kernel_time_t on 32-bit architectures but have padding behind them to allow extending the type to 64-bit. Unfortunately, that fails on all big-endian architectures, which have the padding on the wrong side. As so many of them get it wrong, we decided to not bother even trying to fix it up when we introduced the asm-generic copy. Instead we always use the padding word now to provide the upper 32 bits of the seconds value, regardless of the endianess. A libc implementation on a typical big-endian system can deal with this by providing its own copy of the structure definition to user space, and swapping the two 32-bit words before returning from the semctl/shmctl/msgctl system calls. ARM64 and s/390 are architectures that use these generic headers and also provide support for compat mode on 64-bit kernels, so we adapt their copies here as well. Signed-off-by: Arnd Bergmann --- include/uapi/asm-generic/msgbuf.h | 17 ++++++++--------- include/uapi/asm-generic/sembuf.h | 26 ++++++++++++++++---------- include/uapi/asm-generic/shmbuf.h | 17 ++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) -- 2.9.0 diff --git a/include/uapi/asm-generic/msgbuf.h b/include/uapi/asm-generic/msgbuf.h index fb306ebdb36f..d2169cae93b8 100644 --- a/include/uapi/asm-generic/msgbuf.h +++ b/include/uapi/asm-generic/msgbuf.h @@ -18,23 +18,22 @@ * On big-endian systems, the padding is in the wrong place. * * Pad space is left for: - * - 64-bit time_t to solve y2038 problem * - 2 miscellaneous 32-bit values */ struct msqid64_ds { struct ipc64_perm msg_perm; +#if __BITS_PER_LONG == 64 __kernel_time_t msg_stime; /* last msgsnd time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused1; -#endif __kernel_time_t msg_rtime; /* last msgrcv time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused2; -#endif __kernel_time_t msg_ctime; /* last change time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused3; +#else + unsigned long msg_stime; /* last msgsnd time */ + unsigned long msg_stime_high; + unsigned long msg_rtime; /* last msgrcv time */ + unsigned long msg_rtime_high; + unsigned long msg_ctime; /* last change time */ + unsigned long msg_ctime_high; #endif __kernel_ulong_t msg_cbytes; /* current number of bytes on queue */ __kernel_ulong_t msg_qnum; /* number of messages in queue */ diff --git a/include/uapi/asm-generic/sembuf.h b/include/uapi/asm-generic/sembuf.h index cbf9cfe977d6..0bae010f1b64 100644 --- a/include/uapi/asm-generic/sembuf.h +++ b/include/uapi/asm-generic/sembuf.h @@ -13,23 +13,29 @@ * everyone just ended up making identical copies without specific * optimizations, so we may just as well all use the same one. * - * 64 bit architectures typically define a 64 bit __kernel_time_t, + * 64 bit architectures use a 64-bit __kernel_time_t here, while + * 32 bit architectures have a pair of unsigned long values. * so they do not need the first two padding words. - * On big-endian systems, the padding is in the wrong place. * - * Pad space is left for: - * - 64-bit time_t to solve y2038 problem - * - 2 miscellaneous 32-bit values + * On big-endian systems, the padding is in the wrong place for + * historic reasons, so user space has to reconstruct a time_t + * value using + * + * user_semid_ds.sem_otime = kernel_semid64_ds.sem_otime + + * ((long long)kernel_semid64_ds.sem_otime_high << 32) + * + * Pad space is left for 2 miscellaneous 32-bit values */ struct semid64_ds { struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ +#if __BITS_PER_LONG == 64 __kernel_time_t sem_otime; /* last semop time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused1; -#endif __kernel_time_t sem_ctime; /* last change time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused2; +#else + unsigned long sem_otime; /* last semop time */ + unsigned long sem_otime_high; + unsigned long sem_ctime; /* last change time */ + unsigned long sem_ctime_high; #endif unsigned long sem_nsems; /* no. of semaphores in array */ unsigned long __unused3; diff --git a/include/uapi/asm-generic/shmbuf.h b/include/uapi/asm-generic/shmbuf.h index 2b6c3bb97f97..602f1b5b462b 100644 --- a/include/uapi/asm-generic/shmbuf.h +++ b/include/uapi/asm-generic/shmbuf.h @@ -19,24 +19,23 @@ * * * Pad space is left for: - * - 64-bit time_t to solve y2038 problem * - 2 miscellaneous 32-bit values */ struct shmid64_ds { struct ipc64_perm shm_perm; /* operation perms */ size_t shm_segsz; /* size of segment (bytes) */ +#if __BITS_PER_LONG == 64 __kernel_time_t shm_atime; /* last attach time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused1; -#endif __kernel_time_t shm_dtime; /* last detach time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused2; -#endif __kernel_time_t shm_ctime; /* last change time */ -#if __BITS_PER_LONG != 64 - unsigned long __unused3; +#else + unsigned long shm_atime; /* last attach time */ + unsigned long shm_atime_high; + unsigned long shm_dtime; /* last detach time */ + unsigned long shm_dtime_high; + unsigned long shm_ctime; /* last change time */ + unsigned long shm_ctime_high; #endif __kernel_pid_t shm_cpid; /* pid of creator */ __kernel_pid_t shm_lpid; /* pid of last operator */