LKML Archive on
help / color / mirror / Atom feed
From: Arnd Bergmann <>
To: Zack Weinberg <>
Cc: y2038 Mailman List <>,
	Linux Kernel Mailing List <>,
	Linux API <>,
	GNU C Library <>,
	Martin Schwidefsky <>
Subject: Re: [PATCH v3 01/17] y2038: asm-generic: Extend sysvipc data structures
Date: Thu, 19 Apr 2018 17:51:23 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Thu, Apr 19, 2018 at 5:30 PM, Zack Weinberg <> wrote:
> On Thu, Apr 19, 2018 at 10:37 AM, Arnd Bergmann <> wrote:
>> Most architectures now use the asm-generic copy of the sysvipc data
>> structures (msqid64_ds, semid64_ds, shmid64_ds), which use 32-bit
>> __kernel_time_t on 32-bit architectures but have padding behind them to
>> allow extending the type to 64-bit.
>> Unfortunately, that fails on all big-endian architectures, which have the
>> padding on the wrong side. As so many of them get it wrong, we decided to
>> not bother even trying to fix it up when we introduced the asm-generic
>> copy. Instead we always use the padding word now to provide the upper
>> 32 bits of the seconds value, regardless of the endianess.
>> A libc implementation on a typical big-endian system can deal with
>> this by providing its own copy of the structure definition to user
>> space, and swapping the two 32-bit words before returning from the
>> semctl/shmctl/msgctl system calls.
> This seems generally like a sound approach, but I need to ask whether
> any of the structures involved can ever appear in a sendmsg() control
> message (that is, in the data pointed to by msg_control), or an
> AF_NETLINK message, or any other situation where the kernel
> communicates a structured message of arbitrary size to user space or
> vice versa.  libc can't munge those messages, because new message
> types can be added faster than libc can keep up with them, and because
> I/O primitives like sendmsg() generally aren't allowed to allocate
> arbitrarily-large scratch buffers.

I'm fairly sure that the sysvipc data structures are entirely distinct from
the structures that get passed over sockets, so the question of socket
data is unrelated to this series and will be addressed in a separate

To give some background on what needs to be done for sockets, the
only incompatibility I'm aware of are socket timestamps that
get enabled with SO_TIMESTAMP, SO_TIMESTAMPNS or
SO_TIMESTAMPING and get passed from kernel to user space
cmsg data.

We already have code for handling 32-bit compat applications
on 64-bit kernels, but that cannot work for 32-bit applications
if the kernel has no idea whether the application uses 32-bit or
64-bit time_t, and we don't have a function like in_compat_syscall()
that we can use to find that out.

Our plan here is to change asm/socket.h to have three additional
timestamp flags that correspond to the existing SO_TIMESTAMP*
flags but signify that user space expects the new structure layout
(which is compatible with the existing layout on 64-bit kernels).
For each flag, the kernel then defines a wrapper that (on 32-bit
user space) looks like

#define SO_TIMESTAMP (sizeof(time_t) > sizeof(__kernel_long_t) ? \

Any application asking for SO_TIMESTAMP_OLD will get the
traditional behavior, while applications that are built with a
64-bit time_t will pass SO_TIMESTAMP_TIME64 into
setsockopts, causing the kernel to use the new behavior.
In 64-bit tasks, we probably want to define both to have existing
behavior even though one would never see the new macro.


  reply	other threads:[~2018-04-19 15:51 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
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 [this message]
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:

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

  git send-email \
    --in-reply-to='' \ \ \ \ \ \ \ \
    --subject='Re: [PATCH v3 01/17] y2038: asm-generic: Extend sysvipc data structures' \

* 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).