From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2271C48BC3 for ; Wed, 21 Feb 2024 14:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F0B26B0080; Wed, 21 Feb 2024 09:57:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A0DC6B0081; Wed, 21 Feb 2024 09:57:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2904F6B0082; Wed, 21 Feb 2024 09:57:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 184EC6B0080 for ; Wed, 21 Feb 2024 09:57:49 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A80DC120ACA for ; Wed, 21 Feb 2024 14:57:48 +0000 (UTC) X-FDA: 81816115416.11.48334B3 Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [104.156.224.86]) by imf11.hostedemail.com (Postfix) with ESMTP id 144E940021 for ; Wed, 21 Feb 2024 14:57:45 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of dalias@libc.org designates 104.156.224.86 as permitted sender) smtp.mailfrom=dalias@libc.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708527466; a=rsa-sha256; cv=none; b=tV4VdURrd0tqoX7wn+UMMgPUWDhESNthJ9kBe3VuaLMhlPbNB3A3TRq9d0vQJxGQpR1fPM 4bLe0CiXyYYodsSmrIjOkbQwYSDozyKhCf9WvIg04cUPW+EVViSWS9ZAQzmWnh5A+w3AFx 7G+/DdeXBe2Cbtz43hG/HjWWy5G6KQw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of dalias@libc.org designates 104.156.224.86 as permitted sender) smtp.mailfrom=dalias@libc.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708527466; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1JEWaWpBmq+XYwzEjwtRZR3rudyYWFEE2E7DAvT2pvA=; b=HiRLFQevw/NJNt80mQaDxmKyJWHSNrwqF+MunVfFsOqUhaRfZpmnACK1c/ukbF9shjUWfr 2G8Ia8CJKKmQ/R3MUuG8KkU2+YsoOILYn/0rpGQmhimvYGaremJNp1gEM6ttlc6BefOmN2 N5ZQELvJTucemaRgLfZ7Z1t+G4xBhlc= Date: Wed, 21 Feb 2024 09:58:01 -0500 From: "dalias@libc.org" To: Mark Brown Cc: "Edgecombe, Rick P" , "linux-arch@vger.kernel.org" , "suzuki.poulose@arm.com" , "Szabolcs.Nagy@arm.com" , "musl@lists.openwall.com" , "linux-fsdevel@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "kvmarm@lists.linux.dev" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "catalin.marinas@arm.com" , "oliver.upton@linux.dev" , "palmer@dabbelt.com" , "debug@rivosinc.com" , "aou@eecs.berkeley.edu" , "shuah@kernel.org" , "arnd@arndb.de" , "maz@kernel.org" , "oleg@redhat.com" , "fweimer@redhat.com" , "keescook@chromium.org" , "james.morse@arm.com" , "ebiederm@xmission.com" , "will@kernel.org" , "brauner@kernel.org" , "hjl.tools@gmail.com" , "linux-kselftest@vger.kernel.org" , "paul.walmsley@sifive.com" , "ardb@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-mm@kvack.org" , "thiago.bauermann@linaro.org" , "akpm@linux-foundation.org" , "sorear@fastmail.com" , "linux-doc@vger.kernel.org" Subject: Re: [musl] Re: [PATCH v8 00/38] arm64/gcs: Provide support for GCS in userspace Message-ID: <20240221145800.GR4163@brightrain.aerifal.cx> References: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> <22a53b78-10d7-4a5a-a01e-b2f3a8c22e94@app.fastmail.com> <4c7bdf8fde9cc45174f10b9221fa58ffb450b755.camel@intel.com> <20240220185714.GO4163@brightrain.aerifal.cx> <9fc9c45ff6e14df80ad023e66ff7a978bd4ec91c.camel@intel.com> <20240220235415.GP4163@brightrain.aerifal.cx> <20240221012736.GQ4163@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 144E940021 X-Stat-Signature: i8y641yuyewhqdqw986qebmibjai8q5c X-HE-Tag: 1708527465-173166 X-HE-Meta: U2FsdGVkX18INsFHV7YBUFBURDdozmS3YcC0x43xMoKyxgHPExqA5c9JdNVOWRkBKXxHj/PnlhsLmFAxJ+6pDRHlH8mi0u6Kfc6LSluoP7PIoDPwg1J2tr03XrNb/x9oje2G5Z5x2f49IN/vnsCvU5PwE7IMK8lElxTECZyaP9XKF2WKBi0A6WMn3Gs0c6AxEEha+4U5YdzE7Q4pkV44Rz/Bi7s4UbDOVzK/0pjW+UkTgop28o9vJmi8+SWgidHS7rY/q1FCaXa03QdaGdZgD9fN+RAGXHiyRWBmdFFvcBrEmePgXbpZ2enwGb9MFm5juULfUd057T9n3ZfR4FxOeDAq5uggCgB7tYaA4u+0pKg6ZCkG+V56ODT82bLwHVnv6muu+XPE8u6ZifmR+9xL8iw5/NKvc+4Ltd2rEI9qIDSbfblrL5CEloz2Wbalui6zCbZtIG3MDJxD18oCcZj4pTJfLAib+C3xUWFOhPLSaUgfVbXgxv/Y3xJdmEpywqh1vfp1AlpWZ7VB5Vx6SwkuxSAVkM2XcTbS54sLNbQge7sKtUmohXRD8mfKf/zOq2tTLDP15ENv3bM9n+QZiXEzjWnt+yAib9DokrvD426PwroF6l663EcVRcAIOreO+8ylPSPdfP9Drm8DiJxJL5OKrUyYUR48cov7cIiGVPOtmKP2qoMyudokYjDziJ3F/2LrpL8yxID66ZYK8VxIaw0Q6DBdrSgzQ9pu2Du3keS6DmAtluDNRx0P6Kuwy49v4cxUtEAH1bvTDE0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Feb 21, 2024 at 01:53:10PM +0000, Mark Brown wrote: > On Tue, Feb 20, 2024 at 08:27:37PM -0500, dalias@libc.org wrote: > > On Wed, Feb 21, 2024 at 12:35:48AM +0000, Edgecombe, Rick P wrote: > > > > (INCSSP, RSTORSSP, etc). These are a collection of instructions that > > > allow limited control of the SSP. When shadow stack gets disabled, > > > these suddenly turn into #UD generating instructions. So any other > > > threads executing those instructions when shadow stack got disabled > > > would be in for a nasty surprise. > > > This is the kernel's problem if that's happening. It should be > > trapping these and returning immediately like a NOP if shadow stack > > has been disabled, not generating SIGILL. > > I'm not sure that's going to work out well, all it takes is some code > that's looking at the shadow stack and expecting something to happen as > a result of the instructions it's executing and we run into trouble. A > lot of things won't notice and will just happily carry on but I expect > there are going to be things that care. We also end up with an > additional state for threads that have had shadow stacks transparently > disabled, that's managable but still. I said NOP but there's no reason it strictly needs to be a NOP. It could instead do something reasonable to convey the state of racing with shadow stack being disabled. > > > > > The place where it's really needed to be able to allocate the shadow > > > > stack synchronously under userspace control, in order to harden > > > > normal > > > > applications that aren't doing funny things, is in pthread_create > > > > without a caller-provided stack. > > > > Yea most apps don't do anything too tricky. Mostly shadow stack "just > > > works". But it's no excuse to just crash for the others. > > > One thing to note here is that, to enable this, we're going to need > > some way to detect "new enough kernel that shadow stack semantics are > > all right". If there are kernels that have shadow stack support but > > with problems that make it unsafe to use (this sounds like the case), > > we can't turn it on without a way to avoid trying to use it on those. > > If we have this automatic conversion of pages to shadow stack then we > should have an API for enabling it, userspace should be able to use the > presence of that API to determine if the feature is there. Yes, or if a new prctl is needed to make disabling safe (see above) that could probably be used. Rich