Received: by 10.192.165.148 with SMTP id m20csp4192198imm; Mon, 30 Apr 2018 13:33:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq2IsAsZxbsnb4MtuAqnpS956dxLtZyDxpM3COt24ewso0QcYYuOwRpqok3AKGslRO0LxLC X-Received: by 2002:a65:64d6:: with SMTP id t22-v6mr11152080pgv.41.1525120415316; Mon, 30 Apr 2018 13:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525120415; cv=none; d=google.com; s=arc-20160816; b=idCeeimO4oQf6yzky84kzlYytPFFi95DDHLOdIJFZ0xEHkQ8P7sB7et4y5F7v1/bqM wAl9LOdEr1k/T4KEQK3+UW+Z+r5NUp4uc46eiSLdVOs7+7ecTKD/Ya0qw6awza9PKgFQ dTViO9zrUw/RjyB9SXQxRwB4TU5/psXqGGNsEr4T1dycpplkfxUolN0vhhb47HrXcImi OV8Mn/keQX3YQ+p1dEPKFae1HlVVwHCsvuIXJRo5il8Kiou0ScawAFN9qYZIxOXC05uw KNbNw863hmeleYWhOKgwNiD7ElK1qFHpQJekgUaUQnkYsgwbXFDag5iObRCaO5lp5MnZ ee5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=CUB5hP4f4EppAgt3EDMBTi6HnRRmvWQNzBPnoH0I3E4=; b=I4OWDJhbeHj5pl+AcFu1cHoBVpiI8QEHDrWhz8yleF4rR5Fa1Yh/l6PsNaUj1Enc/Z Vx8PcJWjUr/8RLVeQouvHEbxH8cKQtYCSXI5zzhuL2bsCuTVj25leCCF9nsEiWIQFWFK +wLyZE6BZow7N6LwEDO+DycX4Y8FOSTcPpY0/o8WOrZZimsTrr2Q9cNc8TvIaEFhFTCo EX/FRwQyWeE//cnUy6W1tx90tHWiMeTruhNptToLxYWyzwcFW69z8ibSnr0Nrv29b51Z 17bfqD0Z1TvcjI+BeWK0V/LjNYGM1KYMFZ51s1yJu1K7uWyQTAvNuQS12Q514bZWHNfQ 9uiw== 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 a1-v6si7945965plt.39.2018.04.30.13.32.51; Mon, 30 Apr 2018 13:33:35 -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 S1755679AbeD3Uc2 (ORCPT + 99 others); Mon, 30 Apr 2018 16:32:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:59356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755494AbeD3T0F (ORCPT ); Mon, 30 Apr 2018 15:26:05 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B16022DBF; Mon, 30 Apr 2018 19:26:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B16022DBF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Thomas Gleixner , "H . J . Lu" , Jeffrey Walton , "H. Peter Anvin" Subject: [PATCH 4.4 40/44] x86/ipc: Fix x32 version of shmid64_ds and msqid64_ds Date: Mon, 30 Apr 2018 12:24:51 -0700 Message-Id: <20180430190947.931137994@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430190946.093694747@linuxfoundation.org> References: <20180430190946.093694747@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 1a512c0882bd311c5b5561840fcfbe4c25b8f319 upstream. 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") Signed-off-by: Arnd Bergmann Signed-off-by: Thomas Gleixner Cc: "H . J . Lu" Cc: Jeffrey Walton Cc: stable@vger.kernel.org Cc: "H. Peter Anvin" Link: https://lkml.kernel.org/r/20180424212013.3967461-1-arnd@arndb.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/uapi/asm/msgbuf.h | 31 +++++++++++++++++++++++++++ arch/x86/include/uapi/asm/shmbuf.h | 42 +++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) --- 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 */ --- 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 */