Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1308044rdb; Sat, 18 Nov 2023 10:41:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7xVi0ogcEmyOLd9VwHoi+Lox4PWVRLjspJgEw16mQb3h+GlddNGjOCIQxGwLQMjesSjuA X-Received: by 2002:a05:6a00:2d9e:b0:6b6:9f05:6507 with SMTP id fb30-20020a056a002d9e00b006b69f056507mr2680799pfb.30.1700332889058; Sat, 18 Nov 2023 10:41:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700332889; cv=none; d=google.com; s=arc-20160816; b=YPGDlgu2h2r1VBUlyI4XnaO69hGuhnNl3RHB/1BhWDlzZSNUtQljJ1i2ZWUP6l9tSB 06HfIFpI/3SRj9wLkaazPG/rVNXUpp8+1ygBGXxTo3aMuH6ztDu86GXn4Rpt2UhtHPqh SJ2ZVgwGdwfSpRH9K/m+5IE44fH6xfHuQOmeRJWrkuw0VKVbbkSRBVh8Q//7+srNACSx AA1idV1Kw1oCoj3b646i/657ExGwL9SUVWwuX0QvjAR9UNBFl9tUtGtKCjSAZWhj+MA/ e7J/tmWGRT0r3STYGdJ7Mn9fzhP+gRd1czOsEJFDzN3czAUd6I3CiBrk1HkTXq0zIm+6 Y09w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :in-reply-to:autocrypt:from:references:cc:to:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature; bh=6dLfjLReurv03tG4IC4V2SGJ/1jvrb13h2klhHS6gIw=; fh=9s7wHDxBSIE/bNfv7sidPoFNTf6SedgdaenpP0vQxK8=; b=wefV+EpS3sO/5I8gVizkq4YgxN1JwUH8zb3FRZ3B/Puf3omZHTG6t3yPMOB6tPjKwV t37iPu1LvHdQGV6polmVcdpFsvoWT561dCH4YgRujJuQDZVQ/SEObc8YVfwjc09SZCt7 Yzwd3R64M4R5RdKTB/RicUB5POekvQFJcP1NCu40AouC9FnUAgATtzw6cVnE9hyV9Y53 4AyddAu/2gBpXQ3+J6r7fLEhWtu6s/4Ph+uYxMzIuxZcZ24cmH6eh2be5Fm7ypxOGa5p 90p6LfaVcLfp2lUY+9tQ+d7a+LqnAdKRhPMx524s0PEODOpWjuG5rwgGAt0hyKo6HIPb cq1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=rCkxR6vD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id f22-20020a635556000000b00578cc8d2599si4451622pgm.211.2023.11.18.10.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 10:41:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=rCkxR6vD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4684E8085986; Sat, 18 Nov 2023 10:40:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229650AbjKRSkq (ORCPT + 99 others); Sat, 18 Nov 2023 13:40:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjKRSki (ORCPT ); Sat, 18 Nov 2023 13:40:38 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F60F2; Sat, 18 Nov 2023 10:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700332809; x=1700937609; i=deller@gmx.de; bh=H1zbsRn5uAPqCcioQHkyw4K2MGeXASXOklHwGF80Qnc=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From: In-Reply-To; b=rCkxR6vD5mst3bjYx5rXWLbLnZaKaGzEFA6797pJc+RBsYAfI952EcVmTg2iJfzJ fCY8RPtNVWnsXKRHVyHOih/0ImppqY3FOtnIe6eq9BRl1bUp9HngTznew5aF0tt1y UYyikDC8FBdgKKI0BzATYQAkliRBkJ4YL46TeNVCNPxYdh/GVMSZ0SdfCdh8xDQ/K aqOzxGbb935WphlkGr8D0DJ+FvKICZhrEB1wsaUW+dlGwR3ymX1K7z9vPGL7YCdu+ ANQvmS4CF2lCNPa7nSrCrn3Fk2gGWtlDTbWQ5MbFIXCj2YGkm1ZXU5hO/7kex2t7I 4LXSaUyEZC5rpb4FNg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.20.60] ([94.134.151.152]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MsHnm-1rKaZf32aY-00tmeq; Sat, 18 Nov 2023 19:40:09 +0100 Message-ID: <0f492aac-9ba7-4bc6-95b2-6b1104a12244@gmx.de> Date: Sat, 18 Nov 2023 19:40:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [GIT PULL] parisc architecture fixes for v6.7-rc1 Content-Language: en-US To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, James Bottomley , John David Anglin , Kees Cook , Sam James References: From: Helge Deller Autocrypt: addr=deller@gmx.de; keydata= xsFNBF3Ia3MBEAD3nmWzMgQByYAWnb9cNqspnkb2GLVKzhoH2QD4eRpyDLA/3smlClbeKkWT HLnjgkbPFDmcmCz5V0Wv1mKYRClAHPCIBIJgyICqqUZo2qGmKstUx3pFAiztlXBANpRECgwJ r+8w6mkccOM9GhoPU0vMaD/UVJcJQzvrxVHO8EHS36aUkjKd6cOpdVbCt3qx8cEhCmaFEO6u CL+k5AZQoABbFQEBocZE1/lSYzaHkcHrjn4cQjc3CffXnUVYwlo8EYOtAHgMDC39s9a7S90L 69l6G73lYBD/Br5lnDPlG6dKfGFZZpQ1h8/x+Qz366Ojfq9MuuRJg7ZQpe6foiOtqwKym/zV dVvSdOOc5sHSpfwu5+BVAAyBd6hw4NddlAQUjHSRs3zJ9OfrEx2d3mIfXZ7+pMhZ7qX0Axlq Lq+B5cfLpzkPAgKn11tfXFxP+hcPHIts0bnDz4EEp+HraW+oRCH2m57Y9zhcJTOJaLw4YpTY GRUlF076vZ2Hz/xMEvIJddRGId7UXZgH9a32NDf+BUjWEZvFt1wFSW1r7zb7oGCwZMy2LI/G aHQv/N0NeFMd28z+deyxd0k1CGefHJuJcOJDVtcE1rGQ43aDhWSpXvXKDj42vFD2We6uIo9D 1VNre2+uAxFzqqf026H6cH8hin9Vnx7p3uq3Dka/Y/qmRFnKVQARAQABzRxIZWxnZSBEZWxs ZXIgPGRlbGxlckBnbXguZGU+wsGRBBMBCAA7AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA FiEERUSCKCzZENvvPSX4Pl89BKeiRgMFAl3J1zsCGQEACgkQPl89BKeiRgNK7xAAg6kJTPje uBm9PJTUxXaoaLJFXbYdSPfXhqX/BI9Xi2VzhwC2nSmizdFbeobQBTtRIz5LPhjk95t11q0s uP5htzNISPpwxiYZGKrNnXfcPlziI2bUtlz4ke34cLK6MIl1kbS0/kJBxhiXyvyTWk2JmkMi REjR84lCMAoJd1OM9XG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i9njdxc1wzM9T6pspTtA0vuD3ee94Dg+nDrH1As24uwfFLguiILPzpl0kLaPYYgB wumlL2nGcB6RVRRFMiAS5uOTEk+sJ/tRiQwO3K8vmaECaNJRfJC7weH+jww1Dzo0f1TP6rUa fTBRABEBAAHCwXYEGAEIACAWIQRFRIIoLNkQ2+89Jfg+Xz0Ep6JGAwUCXchrcwIbDAAKCRA+ Xz0Ep6JGAxtdEAC54NQMBwjUNqBNCMsh6WrwQwbg9tkJw718QHPw43gKFSxFIYzdBzD/YMPH l+2fFiefvmI4uNDjlyCITGSM+T6b8cA7YAKvZhzJyJSS7pRzsIKGjhk7zADL1+PJei9p9idy RbmFKo0dAL+ac0t/EZULHGPuIiavWLgwYLVoUEBwz86ZtEtVmDmEsj8ryWw75ZIarNDhV74s BdM2ffUJk3+vWe25BPcJiaZkTuFt+xt2CdbvpZv3IPrEkp9GAKof2hHdFCRKMtgxBo8Kao6p Ws/Vv68FusAi94ySuZT3fp1xGWWf5+1jX4ylC//w0Rj85QihTpA2MylORUNFvH0MRJx4mlFk XN6G+5jIIJhG46LUucQ28+VyEDNcGL3tarnkw8ngEhAbnvMJ2RTx8vGh7PssKaGzAUmNNZiG MB4mPKqvDZ02j1wp7vthQcOEg08z1+XHXb8ZZKST7yTVa5P89JymGE8CBGdQaAXnqYK3/yWf FwRDcGV6nxanxZGKEkSHHOm8jHwvQWvPP73pvuPBEPtKGLzbgd7OOcGZWtq2hNC6cRtsRdDx 4TAGMCz4j238m+2mdbdhRh3iBnWT5yPFfnv/2IjFAk+sdix1Mrr+LIDF++kiekeq0yUpDdc4 ExBy2xf6dd+tuFFBp3/VDN4U0UfG4QJ2fg19zE5Z8dS4jGIbLg== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Zlr9eDagj1n1tz2yMjrmqAQ79OfSCyoyVC/A0HThCCg9Y7AfXrL x+/Wp1kvRHu+T+XyvbdkA6G1ZYRcxA9g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VYQ1o8rNH5 c6RcH/36kYP1LyvEpZlDFnNaVtsLJWPLxhqY5p/5MOmy8Ehv97/ZphHy7t0a8EPx6hQ7Ba14l nA30TgeQYxhDwcliYbruZOg+bwo= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 18 Nov 2023 10:40:57 -0800 (PST) On 11/18/23 18:36, Linus Torvalds wrote: > On Sat, 18 Nov 2023 at 05:58, Helge Deller wrote: >> >> On parisc we still sometimes need writeable stacks, e.g. if programs ar= en't >> compiled with gcc-14. To avoid issues with the upcoming systemd-254 we >> therefore have to disable prctl(PR_SET_MDWE) for now (for parisc only). > > Ugh. > > I pulled this, but I *really* cannot live with how ugly that is. > > Seriously, that code is just unacceptable. Doing something like > > + if (IS_ENABLED(CONFIG_PARISC)) > + error =3D -EINVAL; > + else > + error =3D prctl_set_mdwe(arg2, arg3, arg4, arg5)= ; > > in generic code with no comment is just truly crazy. If you have to go > and do a "git blame -C" just to understand why the code exists, the > code is a problem. > > But it goes beyond that. The code is just *ugly*, and it's done > entirely in the wrong place. > > Things like "mdwe is special on parisc" should *NOT* be done in the > generic "prctl()" function. This issue is not specific to prctl() - > it's very much specific to mdwe. > > So I think it would have been both much more legible, and *much* more > appropriate, to do it in prctl_set_mdwe() itself, where it makes more > sense, and where it matches all the *other* mdwe-specific checks the > code does wrt arguments and existing state. > > And honestly, why wouldn't 'get_mdwe' work? So the *other* hunk in > that patch (which isn't even mentioned in the commit message) that > returns -EINVAL for get_mdwe makes no sense at all, and shouldn't have > existed. > > End result: I think the code should have been something like this > (whitespace-damaged) thing: > > --- a/kernel/sys.c > +++ b/kernel/sys.c > @@ -2394,6 +2394,10 @@ static inline int prctl_set_mdwe(unsigned > long bits, > if (bits & PR_MDWE_NO_INHERIT && !(bits & PR_MDWE_REFUSE_EXEC_GA= IN)) > return -EINVAL; > > + /* PARISC cannot allow mdwe as it needs writable stacks */ > + if (IS_ENABLED(CONFIG_PARISC)) > + return -ENOSYS; > + > current_bits =3D get_current_mdwe(); > if (current_bits && current_bits !=3D bits) > return -EPERM; /* Cannot unset the flags */ Ok. My initial patch was actually doing exatly that, but somehow I finally dec= ided to add it to the switch() instead. Seems this was the wrong decision :-( > where I also picked another error code, because it's not that the > prctl value or the arguments are invalid, I think the error should > show that there's something else going on. > > No, I don't think -ENOSYS is necessarily the best possible error > value, but I think it at least conceptually matches the "this prctl > doesn't exist on PARISC". Maybe > > Maybe ENOSYS should be avoided (prctl() obvious does exist), but I do > think this should be a different error than the EINVAL that the > generic checks do. I agree that returning something else than EINVAL would be better. I used ENODEV in an earlier patch (I didn't liked it either), but accordin= g to https://github.com/systemd/systemd/issues/29775#issuecomment-1809563365 EINVAL seems the best solution currently. Just as a side-note: ENOSYS gives a checkpatch warning: WARNING: ENOSYS means 'invalid syscall nr' and nothing else Would the patch below be OK? It's basically yours but with EINVAL. (might be whitespace-scrambled!) Helge =2D-- From: Helge Deller Subject: [PATCH] prctl: Disable prctl(PR_SET_MDWE) on parisc systemd-254 tries to use prctl(PR_SET_MDWE) for it's MemoryDenyWriteExecut= e functionality, but fails on parisc which still needs executable stacks in certain combinations of gcc/glibc/kernel. Disable prctl(PR_SET_MDWE) by returning -EINVAL for now on parisc, until userspace has catched up. Signed-off-by: Helge Deller Co-developed-by: Linus Torvalds Reported-by: Sam James Closes: https://github.com/systemd/systemd/issues/29775 Tested-by: Sam James Link: https://lore.kernel.org/all/875y2jro9a.fsf@gentoo.org/ Cc: # v6.3+ diff --git a/kernel/sys.c b/kernel/sys.c index 420d9cb9cc8e..e219fcfa112d 100644 =2D-- a/kernel/sys.c +++ b/kernel/sys.c @@ -2394,6 +2394,10 @@ static inline int prctl_set_mdwe(unsigned long bits= , unsigned long arg3, if (bits & PR_MDWE_NO_INHERIT && !(bits & PR_MDWE_REFUSE_EXEC_GAI= N)) return -EINVAL; + /* PARISC cannot allow mdwe as it needs writable stacks */ + if (IS_ENABLED(CONFIG_PARISC)) + return -EINVAL; + current_bits =3D get_current_mdwe(); if (current_bits && current_bits !=3D bits) return -EPERM; /* Cannot unset the flags */