Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp6047178rwb; Tue, 1 Aug 2023 11:25:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDE+pD8fKBlNToiPWW0RTb4o4S5er+Nk67bQsiSHIebP7PB3YdSPJPB7ik76ku9cHt0MJH X-Received: by 2002:a17:906:221c:b0:997:deb1:ff6a with SMTP id s28-20020a170906221c00b00997deb1ff6amr3284461ejs.22.1690914343963; Tue, 01 Aug 2023 11:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690914343; cv=none; d=google.com; s=arc-20160816; b=u3ALgxDGvj8DL6NnXIR76c8ze5KBOXmnvNF+qq8i1i4dGuo9AGr+yqILUrffmJcy3C vz1LCoN+F8sYSX+b3VD3gfhILi2l72JozuA62aFNrmSDKtt50E7IhOEEoql8wuSAKvcn ExXudsa0aAxeztB2CorZQEePR4xV4bSqX3LVb5plzSczvdoxclx231kLfLduQQQMC9h1 Gnoaj1HTLTP8orswpErwGKMjl2/XSA5OG2rmuK8d0pfaML4TFtxTIdk+B1qiJ5Z6eG6d wzOuICVUx0k3Ev4cJS7KRifK9hYYQwcRZ065Icmndk/1CpK8jsyHRHavXD6Flp0c8Grj DmfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=BnvU0KbW34ZEggtd8GRNYFljWI65vc6zfYelD0RpVVg=; fh=oUpr7G/KwwZta2wasXkTDrncyojR97jCpTMFln4bFDA=; b=x/mxzOEVYgm8+tWCI4qE5DABn67R9VyNOmQIeac/3yb1tM3G+bb9NnsAK9u8hSS6Hd 9mw2ad4oJR81PFHjPUFW/Cun6rD+gm2zgSmhgsdyvG17QKXKV5H3Px2cCqbjj6aOO2rp vSd0mkmkbMNE9N3BsO9Pe9nfmL6SWiai+fw91zF2WHxyBvLk9lGFLymK4jQA1JZ1jQu5 lY1EToSmcwdUTeHPJ0TWR0SmzorWtwQcvXMFTdIR95I7dAU+7AzlOrtM1jyig3zUcNlP +yFlJ5T/kM3THd7pEgkcfvfbNsdz1w0OwdjrQGadPEXUkJbWRjrPO8Tkm2DsNhyUQesG jw/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JZJMaAT4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id se27-20020a170906ce5b00b00992ee199abdsi9495475ejb.276.2023.08.01.11.25.19; Tue, 01 Aug 2023 11:25:43 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JZJMaAT4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231893AbjHAR5W (ORCPT + 99 others); Tue, 1 Aug 2023 13:57:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjHAR5V (ORCPT ); Tue, 1 Aug 2023 13:57:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049D11FCB; Tue, 1 Aug 2023 10:57:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8AD526165F; Tue, 1 Aug 2023 17:57:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A047AC433C8; Tue, 1 Aug 2023 17:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690912639; bh=F8CAARuNUeaGEa3yA1waQoVFs2zc6rvh3zubyIWd+RI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JZJMaAT42SQFAM85RnUbpnm4my8uLLOgrzrpv9ey5F7iOsTiCZBEwwsQMLRUS80/H gICFBbZERF2JfuNbCyCasY1N2jUMSPr8iIihwDf950iYsquKfhXkKiL5b+msCXfHuc B0hu58CMAQA41AZ35HEN4GzCtnJS9SRnAzeUVfmqmxuG8PriXB+8iNnYQ9IBFlhh0g 5LHahWPZHyPVmmgOLHdeR6Ip9wxGlCVC4KZ6u6/MqfCxXMrpYZItw3hBiaTqg1xfTN tUOKRiTjydZGF6wuuwu94EdSvPU1tYZYsAoggPLjahr6Dr1QtlFVqW2D4lr8QT0Spn skZg6nLYjJM5w== Date: Tue, 1 Aug 2023 18:57:08 +0100 From: Mark Brown To: "Edgecombe, Rick P" Cc: "corbet@lwn.net" , "ardb@kernel.org" , "keescook@chromium.org" , "Szabolcs.Nagy@arm.com" , "shuah@kernel.org" , "maz@kernel.org" , "james.morse@arm.com" , "debug@rivosinc.com" , "aou@eecs.berkeley.edu" , "linux-kernel@vger.kernel.org" , "catalin.marinas@arm.com" , "hjl.tools@gmail.com" , "paul.walmsley@sifive.com" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "oleg@redhat.com" , "arnd@arndb.de" , "ebiederm@xmission.com" , "will@kernel.org" , "suzuki.poulose@arm.com" , "kvmarm@lists.linux.dev" , "linux-doc@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kselftest@vger.kernel.org" , "linux-arch@vger.kernel.org" , "oliver.upton@linux.dev" , "linux-riscv@lists.infradead.org" , "palmer@dabbelt.com" Subject: Re: [PATCH v3 21/36] arm64/mm: Implement map_shadow_stack() Message-ID: <55c629cc-0545-460b-91cb-2ebdb8ae9051@sirena.org.uk> References: <20230731-arm64-gcs-v3-0-cddf9f980d98@kernel.org> <20230731-arm64-gcs-v3-21-cddf9f980d98@kernel.org> <5461c56cf4896f18bddaa66c3beec7b909fc8fb9.camel@intel.com> <0a6c90d6-f790-4036-a364-d4761fdd0e95@sirena.org.uk> <21d7e814-8608-40ce-b5d3-401f2110ad91@sirena.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="WYhsHyqynSPadbUB" Content-Disposition: inline In-Reply-To: X-Cookie: I thought YOU silenced the guard! X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 --WYhsHyqynSPadbUB Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 01, 2023 at 05:07:00PM +0000, Edgecombe, Rick P wrote: > On Tue, 2023-08-01 at 15:01 +0100, Mark Brown wrote: > > > It could be a different flag, like SHADOW_STACK_SET_TOKEN_MARKER, > > > or it > > > could be SHADOW_STACK_SET_MARKER, and callers could pass > > > (SHADOW_STACK_SET_TOKEN | SHADOW_STACK_SET_MARKER) to get what you > > > have > > > implemented here. What do you think? > > For arm64 code this would mean that it would be possible (and fairly > > easy) to create stacks which don't have a termination record which > > would > > make life harder for unwinders to rely on.=A0 I don't think this is > > insurmountable, creating manually shouldn't be the standard and it'll > > already be an issue on x86 anyway. > If you are going to support optionally writing to shadow stacks (which > x86 needed for CRIU, and also seems like a nice thing for several other > reasons), you are already at that point. Can't you also do a bunch of > gcspopm's to the top of the GCS stack, and have no marker to hit before > the end of the stack? (maybe not in GCS, I don't know...) It's definitely possible to use writes or pops to achive the same effect, it's just that it's less likely to be something that happens through simple oversight than missing a flag off the initial map call would be. > > The other minor issue is that the current arm64 marker is all bits 0 > > so by itself for arm64 _MARKER would have no perceptible impact, it > > would only serve to push the token down a slot in the stack (I'm > > guessing that's the intended meaning?). > Pushing the token down a frame is what flags=3D=3D0 does in this patch, > right? Yes, exactly - if we make the top of stack record optional then if that flag is omitted we'd not do that. > You don't have to support all the flags actually, you could just > support the one mode you already have and reject all other > combinations... Then it matches between arch's, and you still have the > guaranteed-ish end marker. Sure, though if we're going to the trouble of checking for the flag we probably may as well implement it. I guess x86 is locked in at this point by existing userspace. I guess I'll implement it assuming nobody =66rom userspace complains, it's trivial for a kernel. > So the question is not what mode should arm support, but should we have > the flags match between x86 and ARM? The flags should definitely match, no disagreement there. --WYhsHyqynSPadbUB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmTJR3QACgkQJNaLcl1U h9D+HQf/dMO4oPMfSYgpJfSkqjyeMhvngNszJ/vg3XKaq4EJAEMgOh+p9YWNYPyv uBQnGou+Mr2N+ymg2pLC4+WNybCoXsyaVeF/84elK+awSuCxD9GhjtrjqnteBAWg Cjy3FqvlmXwV2AHcXeYANCjGN6BJhmbUKcJp+jwyEU+PNxMrGY4Fyos1o7DlgcDo udN5QQnR8fZ4Xjyv5ZcHWeUX0e5TsB+1e9MK8AOIRkpI52cfHU8u/HSNfOHs5an7 Ugb2wl/4tUWdslzaD4LLg+znjSCYjZ2c0uuIuigxAeFfSDhsFG9C2CiIEaa13iCj rrMq656MkRtw4gwfJ7HGsycFpraatg== =HHRV -----END PGP SIGNATURE----- --WYhsHyqynSPadbUB--