Received: by 10.192.165.156 with SMTP id m28csp869784imm; Thu, 19 Apr 2018 08:53:24 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/NtH6kRcfa7wAA5Mgtwi201QeH+7YzEWGQZ3qtzccfZbEptuOO7ph9E0am6gr1xPUchnBB X-Received: by 2002:a17:902:bc06:: with SMTP id n6-v6mr6492044pls.97.1524153204552; Thu, 19 Apr 2018 08:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524153204; cv=none; d=google.com; s=arc-20160816; b=H6sDK71y9Gc+4yfr+kJE7gbp8LFxmmlK2DIS7PMuH3kIXa0bwfP5Kd+mGv7KNsT170 G1OMKPKF5YlTk0W8eX9Eqsn2XojGMPKnnz4VCz2Ic4LEU16qLuRMdOsy5v7nqpZiU4oD AXX+AYvFwydZZRqWFUL8zSuHVKcRWftWmVSTdNis2OqfaHIa0J8nkpT5H0hfISVu85NP +aF9Qopych/c2UNlgGX6UyPozgVh1sOU5R6Y/gNdxEWOGpGL3UfJxhHm2ZWBIWiGm22S HI76ZpwigzUxF9w1jY1rkmeosnXBwyByQAFLFcCtIOfaZgjJ0jfZGlklXKUoWLzbDnrt h4Jg== 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:mime-version:dkim-signature :arc-authentication-results; bh=XRtWUC6hFrxnPQ+7edz/dnV4thWPO44IEda5udjTDHw=; b=u5OHfo/NQW8rtxCnHLptVREpz9GgWh3QthUWS99sdnev61awumYKw10HgdH9DUU8zQ wKawelZ3zZKIyJWPfTGi6eHtrM7WRNwqxcxhJkCvrjrTkLCPTSDxzPjyNVxPk0hMT0hI MWD4VIrEsOfzhps76hWEiAVJ1Pf03OUcHVjLF+O/gbwRSwfewv7+TS4FusD8I1whYIV6 0WD8UkhxoQfReUHXnx6F1CqZVNqrhKJZ+Xq+6Bk1ip4ufbktfHT2JbWsANGbcGfC7cET 1znxnwvOMXeMKV10UNcmSesHTJBHCs1BGD4xA3A3SUq439iR2+LBHJJ0rIgLaUG1+Pid IawQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Vo3s9H+o; 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 bj11-v6si3614588plb.480.2018.04.19.08.53.09; Thu, 19 Apr 2018 08:53:24 -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=fail header.i=@gmail.com header.s=20161025 header.b=Vo3s9H+o; 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 S1753469AbeDSPv1 (ORCPT + 99 others); Thu, 19 Apr 2018 11:51:27 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:42505 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753251AbeDSPvY (ORCPT ); Thu, 19 Apr 2018 11:51:24 -0400 Received: by mail-qt0-f194.google.com with SMTP id j3-v6so6276717qtn.9; Thu, 19 Apr 2018 08:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=XRtWUC6hFrxnPQ+7edz/dnV4thWPO44IEda5udjTDHw=; b=Vo3s9H+oDDjPfjADnJhzTGYdB9DZUKX3rzfWHoGjGNCS9T38n0hA5KcAGF8FOGAw0B OBwimGGjy4A9fwYXxTLUB45pgXNOheugWIubdP1azKvmv3W8ywu+f1LPKMdDwFCt4moG WJLxQMTIzaJnt4xkHw0t5W0Y8rLRITNryljNT7p2CbX28bbP4w8lY04S3dvQ5RKPhtdi O8Sj/SSY3z1KpTmX4ujRWM2OVuJLTPHhxF6cnLQ8mqdbxWD3OApup2w+BigarGa7EA77 B7bctUI0DMUEcpcW+Cm4PvdA0jYDX2e6ylCt4OeAIchYPyZa/O8nKBaj5NFE87FSrsGh K4tw== 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=NxZbpiq32XW6r0iFeOV+PL/LcOF9KSnzGThkMd2SIV7zg1BQjg2BvGS9rMplQk6/fH 9wZu9P9VlIYO6RUTzJIa73WNIAOk+Hz9uaENatW8akPO0NNMUs7S0+0aQMHvNqdnuV5w nz257JB/u74b81eyEmVVhzk5iL9cv9UIZJGUBw5AARq21SSd2f+qFmkmbs/Tsmwp4Hf+ us+nAcl0qPFCqzLdfx7pWXvOZqL5KPCYalGyKL7EihVka5X3XoZAXpsTuZDg6DtMLEun WtLUROkWQu0dQIxQ0SsEgQO14OVhqLcufsXZ1ae2SASiqfQd17SOnvrUhfCrnB38tQ6c mdWg== X-Gm-Message-State: ALQs6tCLZ3b/Q/jjrtMx+iHSWrtMB6b9/F51w6KRsdFAkhQEmEkOKMz8 lgDkXgT/rOOhmhksKpeILhG5JucOv553NkWuqpBS4vHl 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 Received: by 10.12.185.25 with HTTP; Thu, 19 Apr 2018 08:51:23 -0700 (PDT) In-Reply-To: References: <20180419143737.606138-1-arnd@arndb.de> <20180419143737.606138-2-arnd@arndb.de> From: Arnd Bergmann Date: Thu, 19 Apr 2018 17:51:23 +0200 X-Google-Sender-Auth: jkfyb8ndsFgLuuaCuScy46_CIBE 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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