From patchwork Tue Apr 24 21:19:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 134195 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp59701lji; Tue, 24 Apr 2018 14:20:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpjT0970c/VpXg5JH5EJaV8TpzlPgxkfnwH8JdNiM3cQaF/GlHe2OfemaGjGUosr9vvyb7M X-Received: by 10.98.227.15 with SMTP id g15mr1928412pfh.68.1524604853419; Tue, 24 Apr 2018 14:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524604853; cv=none; d=google.com; s=arc-20160816; b=yG+meBDsl6LUQu7cK3t8vAxoOpSEII2GSFk0TmwMrudIchj2I8qaPpfPf61j3Cwh5e 9YwXw36eYuS9uIZnxpEpYbQjkCZVcL1PjyoSmwOz4u8Ajhyxqo6DqTLI/OEAIpSwLyAf 5F4rHTEI2gpdCv8NAT5kjm5MD94p0iLn35FFhP+lFVuAEXaZM+5pDxFC9WWKh7JSgIqj zab/R3MltD9ql6QFgW/esOtDB4xFua/Z7mllpros532DG61Ruf+Q9ZRdiFWMyJy2UV1R TPzsZ7aiTqjTCk9yiIwJx/Tsf/CYjUXRpph1QDAkSbTiUnyZX5BEQe/Yu+ozeqrh7SvW KQ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HyWjAyZAYEKxxXx2e98O/lN3wBIM2TZdPx1QGVgSsy8=; b=Xfa5kv0j5HieRN4byql6VvGZcFwAXPQW+F6Z/EYUMMMvrVhJZCcLZoC+81rhm1dkKW /XyUFMmt81WziraZc9TcU5yKer7k18l/booXFS22KoFBqKwt6G4usI67DKVeMX+ScW8G PJ3v1WJSRlLuOPzDSqp6pKLBwJ/i1GK4kEfy2y3mp9j1GNJOVwCo3ka+svkGddNTotmb OGFAjwCiS8K7j+mV12TAN6BLj1CTKXeotvAVqjpL5697ztaHqHO7oPbc0eznRrISt8yN eLCo18AkW7RSS7ak6Q7tAH1JREEKikhOoSOsOMARo4GV2X+zsoRvykS5KgRjNW3glXaa Y8Ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 v8-v6si14525825plg.68.2018.04.24.14.20.53; Tue, 24 Apr 2018 14:20:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750786AbeDXVUw (ORCPT + 11 others); Tue, 24 Apr 2018 17:20:52 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:58231 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750772AbeDXVUv (ORCPT ); Tue, 24 Apr 2018 17:20:51 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LkXZc-1eae4z3c4C-00aRQA; Tue, 24 Apr 2018 23:20:17 +0200 From: Arnd Bergmann To: Thomas Gleixner , Ingo Molnar , x86@kernel.org Cc: Arnd Bergmann , stable@vger.kernel.org, "H . J . Lu" , Jeffrey Walton , "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH] [v2] x86: ipc: fix x32 version of shmid64_ds and msqid64_ds Date: Tue, 24 Apr 2018 23:19:51 +0200 Message-Id: <20180424212013.3967461-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:/B1clfbv4/dc4y1z9J6EuQiZHbn4LUucCK9uu0Hni1HUV7ZfI6q ZUM1vIcdk8Ext41oHW71rHZiGZslfHtLoKDnArgFBvR2YuXPGkQD8UP/7SOIi2sE053mRjN YALjXUpGtbdAG9WflH5mEEHDek3TnOQ0S/OOq8xyihD8MKxZF/YS0kmMKxM1R5gFThiJ3Ov NWncsPkqcR5UOc0XTreFQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:N/2nFo6Hc7Q=:DgbZx3k6oMVG8kCIjgSBgE fvmm/ZTEc9aAoHvYCtLOifoKvmTkXfGykpsQyA+f90gAkF36NgroNd8FvCM83ZeV+wk9SZ48Q SCoAqZjDfadm8J6S0p27hCcm995nLu6YC11Xu1sYMgp10mud0sgj0vyLx9EDs+8B5r/lKSozb R6LrAWsfR3o6osMGeG6GMlpx0q6fepyXm4CvHnYuIxgYC26xRYveONI8bjGPMeKjxd9vHFvAs J1iA3Ogmjula0f1Dv3LtYASO4ed9z2YvflkR9GwY4V296BCcScJSNaGiiA1z4AW7phfFnDxGq ioBNX6vfnNiWSr3D2HTVrKdwWAR7vlv9OGHQPQ8XyxA+e1AzDEFhOCQVPqwrZPp/+tqg2gNBj RjtjFF1I3en0lTWcu0BqChM+j5eLvuG76R7GxFROsyE2xp6Ny02RY9WZLwG1w28hN2pllLWPC 5atV9tcgbYlWu2jHXX3o+Ta5o8mVH8n03VumG2Hw5D6DyBJVZ+shCebG1W9sjMHYKWOtrTa2t qp7lmQXwyaGkLGZuJPAD6Q0cjqDDu8Lephz2KLfJ7i2ekJ71DXmQM/lFI7PKjtwOK6XB1ZHoV yRhtPTDs/MpM2M1wo6EEWk5e3g/Eu6A7dzF4gOgmThEfJU0/USjuE05LpWJWAzos596+LgT3M /W+U6shZOD45LOQ4bCgO6McjSbSgW2QvLU1GEaR6yNY2C5vZ0fVAmRZoz/eFlKJwVoetR3D11 SEFUTJwRAzPaSpaR/hXsKKUy1Xy3eH1dfMdQ9A== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org A bugfix broke the x32 shmid64_ds and msqid64_ds data structure layout (as seen from user space) a few years ago: Originally, __BITS_PER_LONG was defined as 64 on x32, so we did not have padding after the 64-bit __kernel_time_t fields, After __BITS_PER_LONG got changed to 32, applications would observe extra padding. In other parts of the uapi headers we seem to have a mix of those expecting either 32 or 64 on x32 applications, so we can't easily revert the path that broke these two structures. Instead, this patch decouples x32 from the other architectures and moves it back into arch specific headers, partially reverting the even older commit 73a2d096fdf2 ("x86: remove all now-duplicate header files"). It's not clear whether this ever made any difference, since at least glibc carries its own (correct) copy of both of these header files, so possibly no application has ever observed the definitions here. Based on a suggestion from H.J. Lu, I tried out the tool from https://github.com/hjl-tools/linux-header to find other such bugs, which pointed out the same bug in statfs(), which also has a separate (correct) copy in glibc. Fixes: f4b4aae18288 ("x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds") Cc: stable@vger.kernel.org Cc: H.J. Lu Cc: Jeffrey Walton Signed-off-by: Arnd Bergmann --- This came out of the y2038 ipc syscall series but can be applied and backported independently. v2: fix typos. --- arch/x86/include/uapi/asm/msgbuf.h | 31 ++++++++++++++++++++++++++++ arch/x86/include/uapi/asm/shmbuf.h | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) -- 2.9.0 diff --git a/arch/x86/include/uapi/asm/msgbuf.h b/arch/x86/include/uapi/asm/msgbuf.h index 809134c644a6..90ab9a795b49 100644 --- a/arch/x86/include/uapi/asm/msgbuf.h +++ b/arch/x86/include/uapi/asm/msgbuf.h @@ -1 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_X64_MSGBUF_H +#define __ASM_X64_MSGBUF_H + +#if !defined(__x86_64__) || !defined(__ILP32__) #include +#else +/* + * The msqid64_ds structure for x86 architecture with x32 ABI. + * + * On x86-32 and x86-64 we can just use the generic definition, but + * x32 uses the same binary layout as x86_64, which is differnet + * from other 32-bit architectures. + */ + +struct msqid64_ds { + struct ipc64_perm msg_perm; + __kernel_time_t msg_stime; /* last msgsnd time */ + __kernel_time_t msg_rtime; /* last msgrcv time */ + __kernel_time_t msg_ctime; /* last change time */ + __kernel_ulong_t msg_cbytes; /* current number of bytes on queue */ + __kernel_ulong_t msg_qnum; /* number of messages in queue */ + __kernel_ulong_t msg_qbytes; /* max number of bytes on queue */ + __kernel_pid_t msg_lspid; /* pid of last msgsnd */ + __kernel_pid_t msg_lrpid; /* last receive pid */ + __kernel_ulong_t __unused4; + __kernel_ulong_t __unused5; +}; + +#endif + +#endif /* __ASM_GENERIC_MSGBUF_H */ diff --git a/arch/x86/include/uapi/asm/shmbuf.h b/arch/x86/include/uapi/asm/shmbuf.h index 83c05fc2de38..644421f3823b 100644 --- a/arch/x86/include/uapi/asm/shmbuf.h +++ b/arch/x86/include/uapi/asm/shmbuf.h @@ -1 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_X86_SHMBUF_H +#define __ASM_X86_SHMBUF_H + +#if !defined(__x86_64__) || !defined(__ILP32__) #include +#else +/* + * The shmid64_ds structure for x86 architecture with x32 ABI. + * + * On x86-32 and x86-64 we can just use the generic definition, but + * x32 uses the same binary layout as x86_64, which is differnet + * from other 32-bit architectures. + */ + +struct shmid64_ds { + struct ipc64_perm shm_perm; /* operation perms */ + size_t shm_segsz; /* size of segment (bytes) */ + __kernel_time_t shm_atime; /* last attach time */ + __kernel_time_t shm_dtime; /* last detach time */ + __kernel_time_t shm_ctime; /* last change time */ + __kernel_pid_t shm_cpid; /* pid of creator */ + __kernel_pid_t shm_lpid; /* pid of last operator */ + __kernel_ulong_t shm_nattch; /* no. of current attaches */ + __kernel_ulong_t __unused4; + __kernel_ulong_t __unused5; +}; + +struct shminfo64 { + __kernel_ulong_t shmmax; + __kernel_ulong_t shmmin; + __kernel_ulong_t shmmni; + __kernel_ulong_t shmseg; + __kernel_ulong_t shmall; + __kernel_ulong_t __unused1; + __kernel_ulong_t __unused2; + __kernel_ulong_t __unused3; + __kernel_ulong_t __unused4; +}; + +#endif + +#endif /* __ASM_X86_SHMBUF_H */