LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	ebiederm@xmission.com,
	y2038 Mailman List <y2038@lists.linaro.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-api@vger.kernel.org, linux-arch@vger.kernel.org,
	libc-alpha@sourceware.org,
	Deepa Dinamani <deepa.kernel@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Albert ARIBAUD <albert.aribaud@3adev.fr>,
	linux-s390@vger.kernel.org, schwidefsky@de.ibm.com,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	linux-mips@linux-mips.org, jhogan@kernel.org,
	Ralf Baechle <ralf@linux-mips.org>,
	linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org,
	Ben Hutchings <ben@decadent.org.uk>,
	Daniel Schepler <dschepler@gmail.com>,
	"H . J . Lu" <hjl.tools@gmail.com>,
	Adam Borowski <kilobyte@angband.pl>,
	tg@mirbsd.de,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
	stable@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86: ipc: fix x32 version of shmid64_ds and msqid64_ds
Date: Fri, 20 Apr 2018 09:53:05 -0400	[thread overview]
Message-ID: <CAH8yC8mnfNnG86kgjnfwiZJ0=qN+w=5PVcLcxddaJdDtYbSanA@mail.gmail.com> (raw)
In-Reply-To: <20180420130346.3178914-1-arnd@arndb.de>

Hi Arnd,

One comment here:

> +#if !defined(__x86_64__) || !defined(__ilp32__)
>  #include <asm-generic/msgbuf.h>
> +#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 <arnd@arndb.de> 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 <arnd@arndb.de>
> ---
> 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 <asm-generic/msgbuf.h>
> +#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 <asm-generic/shmbuf.h>
> +#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 */

  reply	other threads:[~2018-04-20 13:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19 14:37 [PATCH v3 00/17] y2038: Convert IPC syscalls Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 01/17] y2038: asm-generic: Extend sysvipc data structures Arnd Bergmann
2018-04-19 14:59   ` Eric W. Biederman
2018-04-19 15:20     ` Arnd Bergmann
2018-04-19 21:24       ` Arnd Bergmann
2018-04-19 22:12         ` Eric W. Biederman
2018-04-20  8:54           ` Arnd Bergmann
2018-04-20 13:03             ` [PATCH] x86: ipc: fix x32 version of shmid64_ds and msqid64_ds Arnd Bergmann
2018-04-20 13:53               ` Jeffrey Walton [this message]
2018-04-20 14:38                 ` Arnd Bergmann
2018-04-22 12:38                   ` H.J. Lu
2018-04-22 20:17                     ` Arnd Bergmann
2018-04-19 15:30   ` [PATCH v3 01/17] y2038: asm-generic: Extend sysvipc data structures Zack Weinberg
2018-04-19 15:51     ` Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 02/17] y2038: alpha: Remove unneeded ipc uapi header files Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 03/17] y2038: ia64: " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 04/17] y2038: s390: " Arnd Bergmann
2018-04-20  7:54   ` Heiko Carstens
2018-04-20  7:58     ` Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 05/17] y2038: arm64: Extend sysvipc compat data structures Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 06/17] y2038: mips: Extend sysvipc " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 07/17] y2038: x86: " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 08/17] y2038: parisc: " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 09/17] y2038: sparc: " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 10/17] y2038: powerpc: " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 11/17] y2038: xtensa: " Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 12/17] y2038: ipc: Use ktime_get_real_seconds consistently Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 13/17] y2038: ipc: Report long times to user space Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 14/17] y2038: ipc: Use __kernel_timespec Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 15/17] y2038: ipc: Enable COMPAT_32BIT_TIME Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 16/17] y2038: ipc: Redirect ipc(SEMTIMEDOP, ...) to compat_ksys_semtimedop Arnd Bergmann
2018-04-19 14:37 ` [PATCH v3 17/17] y2038: compat: Move common compat types to asm-generic/compat.h Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH8yC8mnfNnG86kgjnfwiZJ0=qN+w=5PVcLcxddaJdDtYbSanA@mail.gmail.com' \
    --to=noloader@gmail.com \
    --cc=albert.aribaud@3adev.fr \
    --cc=arnd@arndb.de \
    --cc=ben@decadent.org.uk \
    --cc=catalin.marinas@arm.com \
    --cc=deepa.kernel@gmail.com \
    --cc=dschepler@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=hjl.tools@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jhogan@kernel.org \
    --cc=kilobyte@angband.pl \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=ralf@linux-mips.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tg@mirbsd.de \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.org \
    --cc=y2038@lists.linaro.org \
    --subject='Re: [PATCH] x86: ipc: fix x32 version of shmid64_ds and msqid64_ds' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).