From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31298 invoked by alias); 19 Apr 2018 15:51:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 31107 invoked by uid 89); 19 Apr 2018 15:51:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=timestamp X-HELO: mail-qt0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=XRtWUC6hFrxnPQ+7edz/dnV4thWPO44IEda5udjTDHw=; b=YDS89Iwn++/D/erSnyxTyaPqDsbH7XxT2SLgf881QTtoqn8m84x1QEy3ayRU/8yVdc nyTP+7wZasGqZZMMpnGKZapMSfJ3/UxHkPyN+wMPKc3y89sqOU9CJB1yLZeHinfKFeBD L5nvd38Uhq6bzTq7IKdMBnqCERBVa0UR7UXoSjTJZOm0/VgIEuBdR8q27AYgdl4NOMKp oshsLN1VBcMUht428nfO3MhJ1n7R/BPuiXqVKlNnr53YhXZZ6BPNihN/TFz1wURuBbL3 Xmjnzp5cHJm1t0nxB67j/TrAo3exXeK08cClMA8+ef4thcs3A0kFNA722gMAPTVyCiez DDBw== X-Gm-Message-State: ALQs6tB2prLIlU0HhrNFxIz2s32xQg8oJ5jqf5Wl++wsbvuw1yXj3evJ DISywxKeB+NsNYmKM62nWpddfGOXJKF6qx1iAzI= X-Google-Smtp-Source: AB8JxZo2/ANMPCi/soAEwZVYhs8/O51+ROWA9vubIIMjBCVhZxyGn2lKKQ8TtETcv3j93nVg07KwOyKHF21zg/AtRj0= X-Received: by 10.12.139.85 with SMTP id d21mr1358849qvc.164.1524153083825; Thu, 19 Apr 2018 08:51:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20180419143737.606138-1-arnd@arndb.de> <20180419143737.606138-2-arnd@arndb.de> From: Arnd Bergmann Date: Thu, 19 Apr 2018 15:51:00 -0000 Message-ID: Subject: Re: [PATCH v3 01/17] y2038: asm-generic: Extend sysvipc data structures To: Zack Weinberg Cc: y2038 Mailman List , Linux Kernel Mailing List , Linux API , GNU C Library , Martin Schwidefsky Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2018-04/txt/msg00420.txt.bz2 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 series. 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 as SCM_TIMESTAMP/SCM_TIMESTAMPNS/SCM_TIMESTAMPING 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) ? \ SO_TIMESTAMP_TIME64 : SO_TIMESTAMP_OLD) 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. Arnd