Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2798317rdb; Wed, 15 Nov 2023 10:44:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmyDyCcQgMkO/onaYONbLsCN3m1x1iBAs/IwPc6aJM9eWIYUifSzJlNQG+lwkbZXeuQ5p5 X-Received: by 2002:a17:903:41c8:b0:1cc:37b9:4953 with SMTP id u8-20020a17090341c800b001cc37b94953mr6418677ple.67.1700073852790; Wed, 15 Nov 2023 10:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700073852; cv=none; d=google.com; s=arc-20160816; b=Lkbwbo6Gdz8MuVFWD8fsd8neMUW2m7KfjDb0nn8JJNSgAe7j3Kt0NVBrfdcwk2dMae UaACaUSYwr/tXs9WCX2YNnYU5HGDtcqYD++PRmTCIeq5e6vWgCTtPqKT67UWGqmq7YpX BksyqmAYG4GbD/5dpGhHsAlJyHxX+TIzXY8ROZ9GQ0vH/ZzQpO2nxnxxk35mogJcq7Xm 8OnjqVr3HyxmvqOWNogH9Zv4bsVVvaCbvfA27Y93Mm2prqLnEGzGmEHS4Po8IPvNbIof 5IRZuN5TS+0EVkv32DKFN6uUa7tsIyDIGXNUEzpQKyVPfr+WyedIWU2wZbr8ayOqm1PL 3m9g== 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=b7NczvX44LRJrHn16P/VLGZjcpa8yLIViuF52vRn7ZA=; fh=TtbSdl5M2UmkgphLllrD2J4/85GJ3cU1O/H9O0LV/Cs=; b=ri1+037djC57Wh5kOod6dD79q2nmQ61kttKQc4c2CCnA2dZTc8ixttnTVvf2OuDrdm 2dNXMKIhCKsi/Rvu0vc5n4njOlq5oafl7feijVeqpqf3DK+yaCbRxgH8GW7/GFHXX3JW 8y3rmL9wy7zCE0WK7WsGicqnCop1IkwCsaIGQ5FaNmEfOD7Hs551+LrVWw/wbGbITNMb MtH9NN+8zRo8ZQblGWmBHDdUR6CnH6VcJ9+aiJlhDUGRk4r7j8ikLeGzewt9k6Uiw7rq sdNYzGpKdGNav3sgrMnpV100deUetPaMcZ+QLTznjK8KMRM76IsqJbF4tbK881RTBV2q 1lyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XsmEj/L6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bb4-20020a170902bc8400b001c9c83947d1si10132778plb.645.2023.11.15.10.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 10:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XsmEj/L6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id D820D8063004; Wed, 15 Nov 2023 10:44:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbjKOSoB (ORCPT + 99 others); Wed, 15 Nov 2023 13:44:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbjKOSoA (ORCPT ); Wed, 15 Nov 2023 13:44:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66C9FA for ; Wed, 15 Nov 2023 10:43:56 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B93FC433C8; Wed, 15 Nov 2023 18:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700073836; bh=Jf1pHHRRqyFoJrFcKBLJXZi9kYmA9sn0zKRsvTYeN9U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XsmEj/L6owfl4Q4us64Fe207eympvsyfuTyF2EFkC5fMypx8x7hX+Nu+WtmRy6P7o vL+ErFVnalcapwhsCuboN+UbPQg/Q1YJ0wjdl9326hv62K1B4Dz44nEDUe9d4Sc8I+ ttk8gVz8Av+XgvRLBGLryPFxAO/2+wI9MEF77VjBWxB0TBXLSDNAGhBKXu2gRLk62n 7CsjxKZG8FolkApx0gMQSqtOts/0dxvlIFp/FtsDSOrx6lhGM2MvmW3AsHRfI4WbhB eWuHir/SH9qYR3lDkRv64kmeL0aCF9NX9+gJQorcgnyipZGYFTIpCcFizBpPuRC4Q3 WcI5drfP9Qbqw== Date: Wed, 15 Nov 2023 18:43:47 +0000 From: Mark Brown To: "Szabolcs.Nagy@arm.com" Cc: "Edgecombe, Rick P" , "dietmar.eggemann@arm.com" , "brauner@kernel.org" , "dave.hansen@linux.intel.com" , "debug@rivosinc.com" , "mgorman@suse.de" , "vincent.guittot@linaro.org" , "fweimer@redhat.com" , "mingo@redhat.com" , "rostedt@goodmis.org" , "hjl.tools@gmail.com" , "tglx@linutronix.de" , "vschneid@redhat.com" , "shuah@kernel.org" , "bristot@redhat.com" , "hpa@zytor.com" , "peterz@infradead.org" , "bp@alien8.de" , "bsegall@google.com" , "x86@kernel.org" , "juri.lelli@redhat.com" , "linux-kselftest@vger.kernel.org" , "linux-api@vger.kernel.org" , "keescook@chromium.org" , "jannh@google.com" , "linux-kernel@vger.kernel.org" , "catalin.marinas@arm.com" , "will@kernel.org" , "Pandey, Sunil K" Subject: Re: [PATCH RFC RFT v2 2/5] fork: Add shadow stack support to clone3() Message-ID: References: <20231114-clone3-shadow-stack-v2-0-b613f8681155@kernel.org> <20231114-clone3-shadow-stack-v2-2-b613f8681155@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jREq/r+U2+vimSwN" Content-Disposition: inline In-Reply-To: X-Cookie: For internal use only. X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 10:44:10 -0800 (PST) --jREq/r+U2+vimSwN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Nov 15, 2023 at 04:20:12PM +0000, Szabolcs.Nagy@arm.com wrote: > The 11/15/2023 12:36, Mark Brown wrote: > > On Wed, Nov 15, 2023 at 12:45:45AM +0000, Edgecombe, Rick P wrote: > > > On Tue, 2023-11-14 at 20:05 +0000, Mark Brown wrote: > > > > + if (size < 8) > > > > + return (unsigned long)ERR_PTR(-EINVAL); > > > What is the intention here? The check in map_shadow_stack is to leave > > > space for the token, but here there is no token. > > It was to ensure that there is sufficient space for at least one entry > > on the stack. > end marker token (0) needs it i guess. x86 doesn't currently have end markers. Actually, that's a point - should we add a flag for specifying the use of end markers here? There's code in my map_shadow_stack() implementation for arm64 which does that. > otherwise 0 size would be fine: the child may not execute > a call instruction at all. Well, a size of specifically zero will result in a fallback to implicit allocation/sizing of the stack as things stand so this is specifically the case where a size has been specified but is smaller than a single entry. > > > I think for CLONE_VM we should not require a non-zero size. Speaking of > > > CLONE_VM we should probably be clear on what the expected behavior is > > > for situations when a new shadow stack is not usually allocated. > > > !CLONE_VM || CLONE_VFORK will use the existing shadow stack. Should we > > > require shadow_stack_size be zero in this case, or just ignore it? I'd > > > lean towards requiring it to be zero so userspace doesn't pass garbage > > > in that we have to accommodate later. What we could possibly need to do > > > around that though, I'm not sure. What do you think? > > Yes, requiring it to be zero in that case makes sense I think. > i think the condition is "no specified separate stack for > the child (stack==0 || stack==sp)". > CLONE_VFORK does not imply that the existing stack will be > used (a stack for the child can be specified, i think both > glibc and musl do this in posix_spawn). That also works as a check I think, though it requires the arch to check for the stack==sp case - I hadn't been aware of the posix_spawn() usage, the above checks Rick suggested just follow the handling for implicit allocation we have currently. --jREq/r+U2+vimSwN Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmVVEWIACgkQJNaLcl1U h9AoYwf/cojm+qZcxUY7dfJP7DC47qY+/XzUzkkr087SF7m5CJpUJMr7YDw+IqHs rSmaGhkeV2BLjb3e4P0UV4bD2pEgfheDGAqNGa5n9fDoQ6O1METyrDUPXco6PZVG lOcLQ/YWO5m8CddEWltolbnnkBasA3UDTXCkkiOtYs+B8d1N7m1XfpA4RGaul3uI L5IcslIwekmr1A5mfqcjeRvw3sh9qesVzDLOkWiTrbfLnPFzzU3aCYej18HttKJ3 4DbBiTpvPnO0bgIMTGT5CL9CXEolecng5cEoZV3CtorIcycMj7hzaftvqC5ezkXB bkm9dunYL/0h1w7pJZ2wxk3h2Tg/ww== =p7qF -----END PGP SIGNATURE----- --jREq/r+U2+vimSwN--