Received: by 10.192.165.148 with SMTP id m20csp292472imm; Fri, 20 Apr 2018 06:56:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/y4iO7Th/TbacdloQLOAf1TvFifGf8gnPlJ4UVvR8KRbzOx/g7NvUhhzpxM37NETI+n9+7 X-Received: by 2002:a17:902:8501:: with SMTP id bj1-v6mr10166545plb.239.1524232579751; Fri, 20 Apr 2018 06:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524232579; cv=none; d=google.com; s=arc-20160816; b=T7Jb2EswR7JGwBfou+BSwre0UQTtE1JJtLG7y1RT22DfSwD9nqttkpRpUx92oeBZY8 Jd6N3AIy94FD4myouhpEJWYcUAiaj2mj7SyRP8Ru8kBIjR3lYIpMtvAeSUSFXHWtY6aw SrraVwUe0MjXTJnoLMIPaTfg5lD03mJU7GkL95mFkr58YgKqol1wjqJoufE7xkifyngG zcEjKgJJwJA1TYTwtWtByO/7r+I4hsCt5cjlyaWtr5veuubHU02M0bsdVg8rWp8gIXpd cI0lCCEneeY2V9+Lc9b/DTn2eMDsVmMZcYviCIKgPAO9ICbXZ6Z+BSI54QU3p1xOGg6v tHgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:reply-to:mime-version:dkim-signature :arc-authentication-results; bh=WkzCoDQr2LgEEY/VlEAKYAmL9GoWZ5T0Ux8T7CXBreI=; b=etsBv7Oa6ALrB3opcy+Socbr7AMCc08Ld06EHRZKRuSU7azaID4Q+IwxFI/f40Uj7U Bm50cbnZd6QoSvIXfN5ZUAVhadMFuKkk9SVZeFYMU14lnKkR9xp0RkB5c9oEIAw8iNyn Rob8JuStcPzmULXAO6ZQ422J5XCCAvRk7Lj/fJxeTuMa8kIqbKcxMpFiZhroyLa6rSYK OaQgzVINrofJa5wjHvhw7SHXQ8U2VytZUUDB+sLnUYJdiE8YY7gGdJE90se48PphvV4j IMB2YQ1El7pmlti5O4MpBLsBpeIyOnZdOnCesQHJEC7kGdF4VjNhwPmnFMYnixHPESTA cFXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ky5q1DgT; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b66-v6si4198421plb.107.2018.04.20.06.56.04; Fri, 20 Apr 2018 06:56:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ky5q1DgT; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755284AbeDTNxL (ORCPT + 99 others); Fri, 20 Apr 2018 09:53:11 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:44978 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755105AbeDTNxH (ORCPT ); Fri, 20 Apr 2018 09:53:07 -0400 Received: by mail-oi0-f66.google.com with SMTP id e80-v6so638839oig.11; Fri, 20 Apr 2018 06:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc; bh=WkzCoDQr2LgEEY/VlEAKYAmL9GoWZ5T0Ux8T7CXBreI=; b=ky5q1DgT0BWWzgrWwPvXxg7J0OsBrp6g8vCPmO3qCniLrPP7MSPLf+1qZEcG37AfK/ em08MNBL10Tl/2GGlYzKnutEsyRYZPfGj3i1Dfm0RXqKEJMfDnt59ZrAMTdf9SuZayFl ZtwbldNqfLVbKmwX1NHyC803IRPIxTZQ69S0olfm6AqJwn0+hmjI5wtErPrMqhb36FqU L24dHCy3yiyqHU7z/NZiHdhDfJ4Stxc8KU9I3qjwgN0BE8+gO1F4Yw9g9suKsQrGCUTL db4oCNjvvJ/zq3DszauxdYDO4R0QCOaEk6WsCCTzaTT0wJwr26GC526s1B9H+DtECU6e XdDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=WkzCoDQr2LgEEY/VlEAKYAmL9GoWZ5T0Ux8T7CXBreI=; b=rkZTgAR31quXFMXWLhBl0dNefM3bPUlSuCxXhxh9kVuu7JCojsgLdkih4+QjeBCSbH fG5IeWet65vlLZrLg2vTi3nE10IqPBxqtI9bFXW9VSjUNeFGVlCel1jwH6rydNFzS9mi 2tKLkd9lWI7ydT/419tXXTpM0ymZpqCV8zvRwBGyIOtpn4jBItBx0aJUQw/rrikGEFeE S5gxX78wcXeX42hHq1fre+rcOSWdeIBGfTaR1BfAm6Uv9fi4hnrEUuQJ4Q+UZOsNFmPs OXf6dXDiKoxy1DPTdJ9jsUdm/sYmKbKS4hxCo6Y+SVNWLdKp/TF2KbSQ1SfZzQJvVjJI NBPw== X-Gm-Message-State: ALQs6tBMZ1GaG1xchrfCTUfARPtfJ8LBT9+kR4Nrg3LE6E+Y/zSLgrSP HimYIgAOXuvgunqJPJKr30vl+ZBnI7JD0o9fue0= X-Received: by 2002:aca:4dcc:: with SMTP id a195-v6mr5931269oib.259.1524232386769; Fri, 20 Apr 2018 06:53:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.62.141 with HTTP; Fri, 20 Apr 2018 06:53:05 -0700 (PDT) Reply-To: noloader@gmail.com In-Reply-To: <20180420130346.3178914-1-arnd@arndb.de> References: <20180420130346.3178914-1-arnd@arndb.de> From: Jeffrey Walton Date: Fri, 20 Apr 2018 09:53:05 -0400 Message-ID: Subject: Re: [PATCH] x86: ipc: fix x32 version of shmid64_ds and msqid64_ds To: Arnd Bergmann Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , ebiederm@xmission.com, y2038 Mailman List , LKML , 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 , linux-mips@linux-mips.org, jhogan@kernel.org, Ralf Baechle , linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, Ben Hutchings , Daniel Schepler , "H . J . Lu" , Adam Borowski , tg@mirbsd.de, John Paul Adrian Glaubitz , stable@vger.kernel.org, "H. Peter Anvin" 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 Hi Arnd, One comment here: > +#if !defined(__x86_64__) || !defined(__ilp32__) > #include > +#else I understand there's some progress having Clang compile the kernel. Clang treats __ILP32__ and friends differently than GCC. I believe ILP32 shows up just about everywhere there are 32-bit ints, longs and pointers. You might find it on Aarch64 or you might find it on MIPS64 when using Clang. I think that means this may be a little suspicious: > +#if !defined(__x86_64__) || !defined(__ilp32__) I kind of felt LLVM was wandering away from the x32 ABI, but the LLVM devs insisted they were within their purview. Also see https://lists.llvm.org/pipermail/cfe-dev/2015-December/046300.html. Sorry about the top-post. I just wanted to pick out that one piece. Jeff On Fri, Apr 20, 2018 at 9:03 AM, Arnd Bergmann wrote: > 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(+) > > 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 */