Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5257888rwb; Mon, 31 Jul 2023 22:31:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUUVfZoyzcNu4lD13Be5F9fQdF1RhpCGmNU1r/9ztwbLQgAP+AhY7t6M5h+IjhJJfZla9S X-Received: by 2002:a17:90a:a58d:b0:263:f7ce:335e with SMTP id b13-20020a17090aa58d00b00263f7ce335emr10200255pjq.43.1690867905461; Mon, 31 Jul 2023 22:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690867905; cv=none; d=google.com; s=arc-20160816; b=iQiVSZ/Fug3opEJ8OgnqLCOmWNw68GoRvNPvpTsSE6Oa8yO3XxQCWOYNQOYvooRvsd 0chzBUS3SmYiNSarHTYy2CIyJjdN7JX2gf9LvzwqDkjadfhVury0NUsBkqrO/64XKoPW 0sLLtDrBCCjMScCLOlPashtfdiqf/HbXl5FK/v1S2UK6AdpJWg5apkaWLaXl/MnpnJ+m sTUdP7uC/RO2j0ssbSttfzcwUxETziAuP6I6LvO3VcYjaOWV+uTRyd0vtUi7u9DdnF7Q 8UlTWiNhMpUUNqQmXCTyZi9jlF5rSeweX6s2O+vLhw3kBz+XS/f/n30S1Ec5VP9Mj9AV tulQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=iC+l9VJV5DrmiMOu3XZ9HLPVhBY1pdOG4ZofauOe6as=; fh=eFnapUXB3INJavh3fnroyXnRIB+dl9pyrdTO80UjcsQ=; b=LLNZKtVk00u8FDlhhRIX/y9hoq+FlF/YaFOrvstfZAXUO+NT3FEIk7KKzAG50nD5aD qL6V3NTAfu/BwS2Gbr6KGiZbnJz/iEGsnAFVCHIwfTcJnnki6OOk/eEW1wrlHS0O/6/8 8YQbL7NAt83eEHnrOArrfLZ78M4hFF+/nKUpRy2gFC4dxSWFO7VgxiwZjiMT/gr25qvR VfrSYTc37g/ZIHcs0rqzZXXJ0MT+cCPU9FmhcOjC3PK21PpuPg/sn6m9X5q3O2dVAJHM ALdVcyYxLyjIQ6gRHnCIpZWDhDZ8EwcPqJ8zQVL8aSkVLGwVZqChbtAvoLq3Uwy0z3OW FB0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id co12-20020a17090afe8c00b0025bdfe1bc66si10035021pjb.165.2023.07.31.22.31.34; Mon, 31 Jul 2023 22:31:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231238AbjHACxt (ORCPT + 99 others); Mon, 31 Jul 2023 22:53:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231321AbjHACxq (ORCPT ); Mon, 31 Jul 2023 22:53:46 -0400 Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [216.12.86.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90DCF1FCA for ; Mon, 31 Jul 2023 19:53:40 -0700 (PDT) Date: Mon, 31 Jul 2023 22:53:41 -0400 From: Rich Felker To: Jessica Clarke Cc: Harald van Dijk , Andy Lutomirski , linux-x86_64@vger.kernel.org, Florian Weimer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , "H. Peter Anvin" , LKML Subject: Re: [PATCH v2] x86: Fix x32 System V message queue syscalls Message-ID: <20230801025340.GA20403@brightrain.aerifal.cx> References: <20201101015013.GN534@brightrain.aerifal.cx> <04832096-ED7F-4754-993D-F578D4A90843@jrtc27.com> <20201101210102.GO534@brightrain.aerifal.cx> <29423184-A433-42D4-B635-CDEFE7271B40@jrtc27.com> <2AC632C0-EC00-4C4E-92DC-B7F238897C4C@jrtc27.com> <347eab9f-b64a-b124-ba7a-ee458e6407f3@gigawatt.nl> <5C330BFF-A81A-465D-BE7D-6DB6A7B263AF@jrtc27.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5C330BFF-A81A-465D-BE7D-6DB6A7B263AF@jrtc27.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 01, 2023 at 02:38:47AM +0100, Jessica Clarke wrote: > On 1 Aug 2023, at 01:43, Harald van Dijk wrote: > > > > On 06/12/2020 22:55, Andy Lutomirski wrote: > >> On Sat, Dec 5, 2020 at 4:01 PM Jessica Clarke wrote: > >>> > >>> Ping? > >> Can you submit patches implementing my proposal? One is your existing > >> patch plus fixing struct msghdr, with Cc: stable@vger.kernel.org at > >> the bottom. The second is a removal of struct msghdr from uapi, > >> moving it into include/inux (no uapi) if needed. The second should > >> not cc stable. > > > > Hi, > > > > This looks like it was forgotten, but it is still needed. Jessica, > > are you interested in submitting the requested change? If not, > > would it be okay if I do so? I have been running this locally for > > a long time now. > > Hi, > Please feel free to; sorry that it dropped off my radar. Part of the > issue is my laptop no longer being x86, making it more annoying to test. > > > There is one complication that I think has not been mentioned yet: > > when _GNU_SOURCE is defined, glibc does provide a definition of > > struct msghdr in with a field "__syscall_slong_t > > mtype;". This makes it slightly more likely that there is code out > > there in the wild that works fine with current kernels and would > > be broken by the fix. Given how rare x32 is, and how rare message > > queues are, this may still be acceptable, but I am mentioning it > > just in case this would cause a different approach to be > > preferred. And whatever is done, a fix should also be submitted to > > glibc. > > Given POSIX is very clear on how msghdr works I think we have to break > whatever oddball code out there might be using this. The alternative is > violating POSIX in a way that makes correct code compile fine but fail > at run time on x32, which is a terrible place to be, especially when > the “fix” is to special-case x32 to go against what POSIX says. I just > can’t see how that’s a good place to stay in, even if something might > break when we fix this bug. Absolutely. The application-facing API absolutely needs to have the type of mtype be whatever long is in the application-facing C ABI. However, I'm not sure how best to fix this. A fix now still leaves applications broken on all existing kernels in the wild. This might be a place where libc should have x32-specific translation code to work around the wrong kernel ABI that became the contract with the kernel. I'm not sure how practical this is, since it seems like it would require a temp buffer. Is the message size sufficiently bounded to make that reasonable? Should there me a new x32-specific syscall that takes the right ABI so that translation is only needed on old kernels? Rich