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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD7FCC52D7D for ; Fri, 16 Aug 2024 12:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SxFmQZI+xdf5mrttY1ApHuWodjs5op+lE2xwGd+e8So=; b=p26rAhKbMC0HBkzQUMYzrBpcA6 5vecKVFPEUF+g9oTjGcwVN4fFkeSG1mMaAVt9oJwxPTs9HmiFb56Z1EFnp6h1XtWlijlyql+uGRIb O2Ik0Lxb8pxUErtMCywMcHrJwczipBDpsbOj6EZHcCXtHniON/xOWkElfSYnn5d0Ff6QHDyEP/lcs PRgvXSbO3eUG3LKw6VZpvbWRCYaVc3B1qfXZoOjReV0iTrTClDkzOa6ljZjBmvCg+0/sTlHn0g1lZ XDbGCy1kzkyZwqc7heWQ0iLAPYDaQE0KN+mRv/cRIyoFYNDPf4yJoEDzwrniO5+XPyMK5RQdzot6g G9MqI5KA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sevsL-0000000CqJo-2Iwg; Fri, 16 Aug 2024 12:16:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seupS-0000000Chqa-0d5Q; Fri, 16 Aug 2024 11:09:11 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7325B620AD; Fri, 16 Aug 2024 11:09:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB36CC32782; Fri, 16 Aug 2024 11:09:03 +0000 (UTC) Date: Fri, 16 Aug 2024 12:09:01 +0100 From: Catalin Marinas To: Mark Brown Cc: Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , Kees Cook , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , Ross Burton , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v10 05/40] arm64/gcs: Document the ABI for Guarded Control Stacks Message-ID: References: <20240801-arm64-gcs-v10-0-699e2bd2190b@kernel.org> <20240801-arm64-gcs-v10-5-699e2bd2190b@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240801-arm64-gcs-v10-5-699e2bd2190b@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_040910_668739_C46FDAA9 X-CRM114-Status: GOOD ( 23.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 01, 2024 at 01:06:32PM +0100, Mark Brown wrote: > +1. General > +----------- [...] > +* EL0 GCS entries with bit 63 set are reserved for use, one such use is defined Maybe "reserved for specific uses". The proposed sentenced feels like it's missing something. > + below for signals and should be ignored when parsing the stack if not > + understood. [...] > +3. Allocation of Guarded Control Stacks > +---------------------------------------- > + > +* When GCS is enabled for a thread a new Guarded Control Stack will be > + allocated for it of size RLIMIT_STACK or 2 gigabytes, whichever is > + smaller. > + > +* When a new thread is created by a thread which has GCS enabled then a > + new Guarded Control Stack will be allocated for the new thread with > + half the size of the standard stack. Is the half size still the case? It also seems a bit inconsistent to have RLIMIT_STACK when GCS is enabled and half the stack size when a new thread is created. [...] > +* When a thread is freed the Guarded Control Stack initially allocated for > + that thread will be freed. Note carefully that if the stack has been > + switched this may not be the stack currently in use by the thread. Is this true for shadow stacks explicitly allocated by the user with map_shadow_stack()? > +4. Signal handling > +-------------------- > + > +* A new signal frame record gcs_context encodes the current GCS mode and > + pointer for the interrupted context on signal delivery. This will always > + be present on systems that support GCS. > + > +* The record contains a flag field which reports the current GCS configuration > + for the interrupted context as PR_GET_SHADOW_STACK_STATUS would. > + > +* The signal handler is run with the same GCS configuration as the interrupted > + context. > + > +* When GCS is enabled for the interrupted thread a signal handling specific > + GCS cap token will be written to the GCS, this is an architectural GCS cap > + token with bit 63 set and the token type (bits 0..11) all clear. The > + GCSPR_EL0 reported in the signal frame will point to this cap token. > + > +* The signal handler will use the same GCS as the interrupted context. I assume this is true even with sigaltstack. Not easy to have alternative shadow stack without additional ABI. -- Catalin