Received: by 10.192.165.148 with SMTP id m20csp5284imm; Fri, 20 Apr 2018 01:55:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx49VEv3U6TifvMkOtdFvSv2wpOqcyxJB9b3kpHOEtikMovmYrJ+bwpUJuV5kh4YFXQW6ZdzY X-Received: by 2002:a17:902:9a8c:: with SMTP id w12-v6mr9513152plp.333.1524214556389; Fri, 20 Apr 2018 01:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524214556; cv=none; d=google.com; s=arc-20160816; b=wgNJENc0D6ctKMxibUXHXAoYBoxP2IZV4s8ox3dRqlXWMknMrCpX2lYrAo6K3HWJR7 KMRi8T00w1D29pxTldpMXhufPsyfNXvClT7pJ4axLmaMYTwzs0521Lbd09jP9IXNV0iI ftFAQi3XzexJvd4DWzLbn+CgFlBN0fnMWwd1FqOrki93eIRVIMT7jCJ2AvNOnizLW4G/ +UIod5sJi+OlBmoawVKmBpld+8dMPwuHMBeS+VWiLmnL16JPmXRY72KM8WUfKl/y7VIu ic56fvSpEimi5rqb1htK4GKKIy5+10mMrehrNDfUZzq0COs802hPaXRB9bSOCHXn9Vrg UNVQ== 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=u0SlBa3kExqllCTvIwYgpOnqwTg98nZ1vcreS4mqD1M=; b=RWecAKQEZjLva8dgEJOltmKyPFWXsrpGb9L/x890VMUVXy+2chw09v2rxdrc1+gFoi 00Nnh2eIuJSFEA2i2lbl6n2O6xwfi7nyK3ruBHBAJ5Kx+uHiQbqr436T82gKcAVUHZDJ vGwTjXTvJVTRUv5Q/RGAD3ss8OmxuuTFNWly7cvJ8EzojGNiLnxykOWOhSVqqTk6HPuW nv+RtmCuqy/kTMczX+1SlYzNHNIlgwmorrixXIAlYLX+GG8y61gN8BjeUu9AihpUrO19 YICQMzgubnD/2C2SmKCOCkrGajinrD/n86RlagyxgnuDA7t59w4ITHgLCaGoeJuST7ot Yn7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BuLEFbtD; 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 s72si5081184pfa.252.2018.04.20.01.55.41; Fri, 20 Apr 2018 01:55:56 -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=BuLEFbtD; 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 S1754335AbeDTIya (ORCPT + 99 others); Fri, 20 Apr 2018 04:54:30 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:35888 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754307AbeDTIy1 (ORCPT ); Fri, 20 Apr 2018 04:54:27 -0400 Received: by mail-qk0-f195.google.com with SMTP id a202so8188236qkg.3; Fri, 20 Apr 2018 01:54:26 -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=u0SlBa3kExqllCTvIwYgpOnqwTg98nZ1vcreS4mqD1M=; b=BuLEFbtDxKskjQ7YRGItusQ5j4RqTAv0k5mA0uQi0+GNdqliMtQ4wWFhqGKoT0tLuA CkNbnE84XpdsE1YlB4frvKcIq97b+O0ZZVv9MDasYZzYmUokaWEwHJtxKc1h8jLtUJa7 v+qWPJUcgjOSBmk11cSxN/St+s6tFYsTpFupxUIAPtPOwxbmGSm7QTRfmnkOD2lecjl3 VDpDKnViSaIk5JiJstwfYDrZl3s7MXG5zIW+UtV6aj2E7WPNPBm/LRkDAaLUwAeTWYBt kOqKeloI6XotI6ZYTEthPfzAJG8uvB1rPuAFZPfbUpHInRqBUMWxe+YrphKqK7QxP5sO mGVQ== 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=u0SlBa3kExqllCTvIwYgpOnqwTg98nZ1vcreS4mqD1M=; b=hLrLxC7gwrCdeurkmU/+TkTRbu1LBDZoUk+p1P5x5PFG4BjkxjNK67rYdhwgHiiWKR 17qWNL9nLsSONur//uv8gZagxjQcQFpRXWbQyHWJOSm7l7mE8qpJkQn9OdP72fyjpMZ2 SMYmR0y9KiEJ8AqSlsh/EfVrdr4FSc19d9ALrFpQ3vPSXG5AkjMcvlgQAxsJnXt7yvM/ yfQvsOX8qa704F89Gk+QRreKks26LqgW8uCl8TrkJW3RvMg9zqFhMseSapHfNyJI1Xmj 43wJwUTXUtijIl9gVHAVyWMU0kY3v9XK0QVzblBRPw+f1g9N+J0qQdookPkEj6U+8NyT Az/Q== X-Gm-Message-State: ALQs6tBT5Y5C3Q54F7Lsj2nqiAvpEssgiqtgeKWEHplMZ1IeFTDayFvk qEZKF7V3ZgTmzZX7Y1pwU8XGsE+chriyWOf1U9gXi4q7 X-Received: by 10.55.180.1 with SMTP id d1mr9191714qkf.283.1524214465778; Fri, 20 Apr 2018 01:54:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.185.25 with HTTP; Fri, 20 Apr 2018 01:54:25 -0700 (PDT) In-Reply-To: <87k1t2n8v5.fsf@xmission.com> References: <20180419143737.606138-1-arnd@arndb.de> <20180419143737.606138-2-arnd@arndb.de> <87efjbnswr.fsf@xmission.com> <87k1t2n8v5.fsf@xmission.com> From: Arnd Bergmann Date: Fri, 20 Apr 2018 10:54:25 +0200 X-Google-Sender-Auth: tOfzH-co8L5k2AQrWlQ-PMWJMfw Message-ID: Subject: Re: [PATCH v3 01/17] y2038: asm-generic: Extend sysvipc data structures To: "Eric W. Biederman" Cc: y2038 Mailman List , Linux Kernel Mailing List , Linux API , linux-arch , GNU C Library , Thomas Gleixner , Deepa Dinamani , Al Viro , Albert ARIBAUD , linux-s390 , Martin Schwidefsky , "the arch/x86 maintainers" , Catalin Marinas , Will Deacon , "open list:RALINK MIPS ARCHITECTURE" , James Hogan , Ralf Baechle , linuxppc-dev , sparclinux , Ben Hutchings , Jeffrey Walton , Daniel Schepler , "H.J. Lu" , Adam Borowski , tg@mirbsd.de, John Paul Adrian Glaubitz 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 Fri, Apr 20, 2018 at 12:12 AM, Eric W. Biederman wrote: > Arnd Bergmann writes: > >> On Thu, Apr 19, 2018 at 5:20 PM, Arnd Bergmann wrote: >>> On Thu, Apr 19, 2018 at 4:59 PM, Eric W. Biederman wrote: >>>> I suspect you want to use __kernel_ulong_t here instead of a raw >>>> unsigned long. If nothing else it seems inconsistent to use typedefs >>>> in one half of the structure and no typedefs in the other half. >>> >>> Good catch, there is definitely something wrong here, but I think using >>> __kernel_ulong_t for all members would also be wrong, as that >>> still changes the layout on x32, which effectively is >>> >>> struct msqid64_ds { >>> ipc64_perm msg_perm; >>> u64 msg_stime; >>> u32 __unused1; >>> /* 32 bit implict padding */ >>> u64 msg_rtime; >>> u32 __unused2; >>> /* 32 bit implict padding */ >>> u64 msg_ctime; >>> u32 __unused3; >>> /* 32 bit implict padding */ >>> __kernel_pid_t shm_cpid; /* pid of creator */ >>> __kernel_pid_t shm_lpid; /* pid of last operator */ >>> .... >>> }; >>> >>> The choices here would be to either use a mix of >>> __kernel_ulong_t and unsigned long, or taking the x32 >>> version back into arch/x86/include/uapi/asm/ so the >>> generic version at least makes some sense. >>> >>> I can't use __kernel_time_t for the lower half on 32-bit >>> since it really should be unsigned. >> >> After thinking about it some more, I conclude that the structure is simply >> incorrect on x32: The __kernel_ulong_t usage was introduced in 2013 >> in commit b9cd5ca22d67 ("uapi: Use __kernel_ulong_t in struct >> msqid64_ds") and apparently was correct initially as __BITS_PER_LONG >> evaluated to 64, but it broke with commit f4b4aae18288 ("x86/headers/uapi: >> Fix __BITS_PER_LONG value for x32 builds") that changed the value >> of __BITS_PER_LONG and introduced the extra padding in 2015. >> >> The same change apparently also broke a lot of other definitions, e.g. >> >> $ echo "#include " | gcc -mx32 -E -xc - | grep -A3 >> __kernel_size_t >> typedef unsigned int __kernel_size_t; >> typedef int __kernel_ssize_t; >> typedef int __kernel_ptrdiff_t; >> >> Those used to be defined as 'unsigned long long' and 'long long' >> respectively, so now all kernel interfaces using those on x32 >> became incompatible! > > Is this just for the uapi header as seen by userspace? I expect we are > using the a normal kernel interface with 64bit longs and 64bit pointers > when we build the kernel. Yes, that patch shouldn't have changed anything in the kernel, which continues to be built with __BITS_PER_LONG=64. I haven't checked the vdso, which is the only bit of the kernel that gets built with -mx32, but I assume it's fine as well. > If this is just a header as seen from userspace mess it seems > unfortunate but fixable. Right. I'll fix the IPC stuff for this series to make it work with any value of __BITS_PER_LONG on x32, but I don't plan to do anything about the rest of x32. The patch that caused the problem was intended as a bugfix, so we can't just revert it without first understanding how to properly fix the original bug, and which other interfaces have now come to rely on __BITS_PER_LONG=32 for x32. Adding a few other folks that have been involved in the x32 kernel support or the Debian port in the past. Maybe one of them is motivated to figure out how to fix this properly. Arnd