Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2409029rdb; Wed, 21 Feb 2024 06:58:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUvTDmYehgvgcQqHZUVIoo8H0GeJlbuI2uwGhobIU6xGTiRV66z97ekHyh5Zg20erZQ69MLNnh4DJ2qj6TYMmd3TcLFN6EBTLpNnfSc5w== X-Google-Smtp-Source: AGHT+IGiRAIbIVMO70LZqggPbuDqnukGzQ8O5RU57UXVfqS8icI6+HA7lMxfcIYo86fRzz+4XGiO X-Received: by 2002:a05:620a:610f:b0:787:4e6a:4ed0 with SMTP id oq15-20020a05620a610f00b007874e6a4ed0mr13767155qkn.2.1708527481562; Wed, 21 Feb 2024 06:58:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708527481; cv=pass; d=google.com; s=arc-20160816; b=HDhRyThePQR5vI3ExZC8jMi6BAo8bFynB+uwlkddVGHtRG8n/pbv++G/7/Qi5jpxOO 61QoJrWAtioEHI2HVEZXJM6c7JQDm+NQ/4QqpI4x6LrGy+7+sIo64CGQfKBV7D3m+dLn WLWGRAPckOpn6bv64Xt/sircOOwdn38hc2In1hFbiOybaxSE59ee0tvtxo4wEoOr8X+g ym2zhdMuGfl+BONjo/e2ie0ZNcb7P9xR69MOzCEswlp0jaaFkwPm3lf3L8cZY/o/VEd9 ajmu2NvSFWzrO4Hh/jMHX7+FyLeu3JCl/vZBqDKbjrUuFCGH48CWhFKGNRh7CDn68C1a gUOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=1JEWaWpBmq+XYwzEjwtRZR3rudyYWFEE2E7DAvT2pvA=; fh=h66ctbSzkMNhsY77BYxeoc13/7gQM34x4dIrYIml524=; b=gy06l5CpneNFIolaE/o1JtvqY/5MxtDkn30oPKCIgCW9+0MtnkFxMmqajR/v8Ce75d dAhZH/xw3ukfLUbH/vSssPSZql7CFyhbb+RC7HVtFkuuL9I1Q5S28U3uJWnSpZ/pBqc9 TB7B/sayGfC68UNBMnS2fK3XmhfhdHgiQS0q3lVJ5v3r/I+IDjGSL67CdO88+fcHHU6a nvd7kuLJ0W5EGLFEkEP5f3rDKGWPId8IYXJek3zW8xM/QRa+FHQmTRy5YjeQ8WxuqKpM juROZCPr1gXfSwY53FgGeqpsqweXe5lVk2uTWgjPUN4oijbP2AZ7kwHtOzejoPgooBwD OdRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=libc.org); spf=pass (google.com: domain of linux-kernel+bounces-74949-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74949-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id qp28-20020a05620a389c00b007876c7c18f3si5967089qkn.374.2024.02.21.06.58.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 06:58:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74949-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=libc.org); spf=pass (google.com: domain of linux-kernel+bounces-74949-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74949-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C7B01C238F1 for ; Wed, 21 Feb 2024 14:58:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDF507FBD7; Wed, 21 Feb 2024 14:57:48 +0000 (UTC) Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [104.156.224.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4748E7FBB8 for ; Wed, 21 Feb 2024 14:57:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.156.224.86 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708527468; cv=none; b=YHchI7S8BAn5vQwILdL+Trd3dUcN71OSrMlT4E9EAJGmkGonzDvNd6ovOTy4CApO46Nv+5TRkSSU+6PDRd+dogCjdphWKobvrimdQXAUnXWTWaARnZBCuh8S7hMzF9MPKJmZogo2t8Z1poPdyEXLQFLqd+RIpAbQ5WhUlzgYMKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708527468; c=relaxed/simple; bh=VXm+kZmxMVHqvGGNho4lRaBPvFnNMXrsUkhaZtCVkdg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=di+Ph33/9JeP4ALbeKH/nteq+3JqDV4ThjtqH9emARidu3obJZKnTZ6LQ/AfmrvZbXi99bmQ14l+B9jpfL0t9wBVDY03RS2xEjZPv7E0ulhBrMDklvjf1iGBCamM/ZPbKnCK198k9kNEnqB3LS3eOFxGk6/DK17wTzGBt5aEWRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=libc.org; spf=pass smtp.mailfrom=libc.org; arc=none smtp.client-ip=104.156.224.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=libc.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=libc.org 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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) 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