From patchwork Fri Apr 20 13:03:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 133877 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp259768ljf; Fri, 20 Apr 2018 06:06:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/2sNBCvbc9ciaoX3hKRM5N9bldZwbgnqxUsO0rOZ/Zw4okNyXF2UaepccLV0N8JJ9FeNUP X-Received: by 10.99.120.138 with SMTP id t132mr8564151pgc.280.1524229560514; Fri, 20 Apr 2018 06:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524229560; cv=none; d=google.com; s=arc-20160816; b=CHAND16VyY2Z94xNlIBe4/m6R4H+0OMWl7gaERJa3FDXwFjp8RHPwGhrMp33WShlaz BtXqTCtQPxa8I+FDE3JdGfOevW27HC7JXN8R+dRHdiSchgvd/UlS1Jmu6Pm4dj5CxFFz ksp5J6vv6rxQQr2lk9IRJWMAZ+yiePNhYXZ+Se1i69SQuhXt2uJEd7j9e37onE6G9vNH nNmBhMzdxJ9mFes1itoszAXDRpheBB6GzSk8MiyJJaSqAPp5XGmhT8eTvku/GGtrKl6p jK1ehDeqMes017txy89tl8bxQOHo6fYAit20PMc+V8UxR3iWpdwSSx1Jc1TSbTE1k2st +uxA== 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=lRPDox80EIknxUrKHZMpkCRPN4I10Vculgb2kpFHM3Y=; b=vAfl198dIf8vS4q5I7j7/lyYLJRixqEKv4LAcQUVj05+3okckUhR0fFqVmxOtRA7PU en7DfBOPK3KUjgSUBX/DSxE+tWc+coKC5FeKJQ8XfEiiXMKgc+f4ytJfgqfN7WIuTqdG ainkVbyxAdBHp1okFj+A1pwAT/44CHi6NJbCfjjCP9UOYpm1r0zpmF1LLhjZi7SN/Uy0 RLYDXMe04f5Os5kkQy8oLQD1su2tQ2iQv3ql0ettM7/+ct0d1Cqym91BOWD2gj88kaNk cya7SgMIZ8qmtuV3wasA3cjE7/dYVJ4+1q8T5P4sN4Edor6YSlFmb3nqeeYpCwbnTeTs iggQ== 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 9-v6si5829908plb.415.2018.04.20.06.06.00; Fri, 20 Apr 2018 06:06:00 -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 S1754917AbeDTNF6 (ORCPT + 11 others); Fri, 20 Apr 2018 09:05:58 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:34327 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754764AbeDTNFy (ORCPT ); Fri, 20 Apr 2018 09:05:54 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0LdQZe-1ejUbv3VkQ-00ij3Q; Fri, 20 Apr 2018 15:03:58 +0200 From: Arnd Bergmann To: x86@kernel.org, Thomas Gleixner , Ingo Molnar Cc: ebiederm@xmission.com, y2038 Mailman List , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, libc-alpha@sourceware.org, Deepa Dinamani , Al Viro , Albert ARIBAUD , linux-s390@vger.kernel.org, schwidefsky@de.ibm.com, Catalin Marinas , will.deacon@arm.com, linux-mips@linux-mips.org, jhogan@kernel.org, Ralf Baechle , linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, Ben Hutchings , Jeffrey Walton , Daniel Schepler , "H . J . Lu" , Adam Borowski , tg@mirbsd.de, John Paul Adrian Glaubitz , Arnd Bergmann , stable@vger.kernel.org, "H. Peter Anvin" Subject: [PATCH] x86: ipc: fix x32 version of shmid64_ds and msqid64_ds Date: Fri, 20 Apr 2018 15:03:29 +0200 Message-Id: <20180420130346.3178914-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: References: X-Provags-ID: V03:K1:s4pXsIJyLTMXyL6KgDWw8XcyU9mNufw2Dpp+Cebn4jG13dUGY1C kn25mDG58Ah63DpYCMjhtr8DYRnDjCfrvfn5jaKQMUHjw1tpPHOJoGc8dZsjw4nAbEt+pif yrYJo7Zl6AzsSODDBse03XbXGmH+jIYec0rD1Smc2TO5xWlh3yUKiBil7oCpMcQtlMxFaTB SaAS2zRvYqvXwE4IKVchQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZdrNTAdpv9E=:toj5rfEn+T28bZ7LpkA/HI cNYVyEd8cQ+9S5H4Gy20PQeDPjv3Cb2Y5eJN2flMvk5PNzUz0xsFUnmFX9SgYpIk/X5UJD8vd JMa9EBEHiFW1rWMFCSvBD3NJ7aHps9vbPlX9FUn8v0+6RCkujkg8QW3FKDX7TFB5CWyobkDxC T6t8sgGkY04OilcPlQRpoWaKXy4gHM4LD4bqo5HdePlT3fdJAjVnrBqayamHtWChxcn7EWiH5 lbwfrUanuhRMNJi9BI3IxE94tQLZhFSgAPRrSH3P3xn7rHSGo1touSNrPehKhF1WRgqvSzd3U N5LtsxWvT5AKozDqUaEgNS0aV+1xU9R9vx9Xf6cVgljDR/5y2QySg9a1mWaDekGztuBGDg7ZN rW5QpWNMlt4Uimic2l1Shp1O09Bz8ZFSmeKWa+DwCaLknI0M9Bxy4l6p7RfcfT2NVydqW177b fHktiY4rJb9MV6B+mXRFFRAB23/Hz2BndmJX7bkZkgFcPB/riPq0b2Ezic6yImJAM7vZSwav6 s49+/3ihU8y1P6ycpG0L/JmuacuSWFTHaPQNQdnNUVLwQx7adRnhMJY9ZVIgW/pQdQLq7kgMf qQru3sXaBJddqmAmmF4Az5i9+y3pQp+MCocilev/2IeESmgbRfYZTdAtBL29jU7ngHGki8A+o gjINkRAmxFnZHPvaZyNSLrxP93r+9QrzYXBaYgjkp/ba+FGqBeeoJtIpo2nbbTB0vHTJQmBAb +FVCERHJJI7o9C4KYnyQ/noDwNW6dHcDlJ+7dA== 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. There are other UAPI interfaces that depend on __BITS_PER_LONG and that might suffer from the same problem on x32, but I have not tried to analyse them in enough detail to be sure. If anyone still cares about x32, that may be a useful thing to do. Fixes: f4b4aae18288 ("x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds") Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann --- This came out of the y2038 ipc syscall series but can be applied and backported independently. --- arch/x86/include/uapi/asm/msgbuf.h | 29 +++++++++++++++++++++++++++ arch/x86/include/uapi/asm/shmbuf.h | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) -- 2.9.0 diff --git a/arch/x86/include/uapi/asm/msgbuf.h b/arch/x86/include/uapi/asm/msgbuf.h index 809134c644a6..5f1604961e6d 100644 --- a/arch/x86/include/uapi/asm/msgbuf.h +++ b/arch/x86/include/uapi/asm/msgbuf.h @@ -1 +1,30 @@ +/* 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 /* __ASM_GENERIC_MSGBUF_H */ diff --git a/arch/x86/include/uapi/asm/shmbuf.h b/arch/x86/include/uapi/asm/shmbuf.h index 83c05fc2de38..cdd7eec878fa 100644 --- a/arch/x86/include/uapi/asm/shmbuf.h +++ b/arch/x86/include/uapi/asm/shmbuf.h @@ -1 +1,41 @@ +/* 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 /* __ASM_X86_SHMBUF_H */