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 ABCF5C531DF for ; Fri, 16 Aug 2024 11:09:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EBE76B030C; Fri, 16 Aug 2024 07:09:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 29D7B6B030D; Fri, 16 Aug 2024 07:09:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1644A6B030E; Fri, 16 Aug 2024 07:09:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id ECD8A6B030C for ; Fri, 16 Aug 2024 07:09:12 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5F77A141A70 for ; Fri, 16 Aug 2024 11:09:12 +0000 (UTC) X-FDA: 82457836944.21.8A806AE Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id AF05C1A0019 for ; Fri, 16 Aug 2024 11:09:10 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723806452; 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=SxFmQZI+xdf5mrttY1ApHuWodjs5op+lE2xwGd+e8So=; b=uSUjbvlIhHLtesU9ChSlWGQLMQfYKGuQm0r5rVXVEuOVc/j1dgjZHULQ+fyeuXpCaKOPe0 iQ+sxOFygz7dGESjxEI04Des+XL5xZnCqzsPZwkTMY6iwmlW9kDfAgMRtP9B0VPfkmCIaY CWYIeOwwGaeLPuyDtViisf+8PVaP2hM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723806452; a=rsa-sha256; cv=none; b=oe7eeABKtICiBV0zkVSrB1SkebccnYGivk7Ub+0NO7AJHfqqiNFfz/18r9lrm3FKTbOsnq zeOJZP0Bz73kcGF4S4Mke3zmwl/ShSRkP1NK6CQmJ/mZhC/UDnYtGq6o9+kqkVESJrmVBe GTpiaG0Oq7cjnARdxGHknPFQPqquWlo= 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-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AF05C1A0019 X-Stat-Signature: 37oxx8p6jk8989rgou8psipf5ybua8xo X-Rspam-User: X-HE-Tag: 1723806550-405912 X-HE-Meta: U2FsdGVkX1800jQ2WTMDqlYqLH64wd2QEjaJmIjgBKHiq21UJ6usNY50AP6KK/1G6rvrFHJW6WY13osWIWEwm7HaxaxruMIV24vIHjQ4ERWRQbWVYnF+MJ8BwKAPp7gUFcljCYsrhf1lh30mQC8gPE91xGgRjGBMERnzknYyzH97+9w/uPcw3vyJwVrFFSh1l2KRf4W/43blC52Ng0Jm7R92Suoi7x9U+KWsZYbZYmUtB1YQVbmzYz7JRwxzlIgISLnmaiKZjS/Iw+vfThKSrkjSW2/od26S+SSYqPaTb78LtTgAGPC/9X1Rv1PJIeIAVMzaQ/8hqXpmC6JUZrOCI2v37z/2fqdxC0HyAzaEpiRMB2XlOAFm5GjXBdJP/UfyLl18MHcpGLEukGqncNSGvfrSng6fyuHhFUMeISLiZf7pJ11gJLe74yr/0cirlR3medrGwcOHmh0+rCF5QGoIKsY7oXSulJjUsD48B52NcJrwzR2e2yAMcW4hnjTrdJXVgGT3lwnQZ4a+LMZlHmJiMBRc5RFsQhUOksyyppmafb5hW8TNku76RpkMA/VSqf1LG+b3TcaLecRTnW14KvpVnp43KBXYrTZCVu7QvJeoX5ih1axrwHg9rFiSHZvvWHIjLRrL4y+rFEN01Rs/bDTyNS+3c4f+hd2txp5iprDHSIFUHi8ym6un2mTDlBc/q6NqH4O6b50dvAdXP221eslGWZz7i8DHfodb5XLsSquqkX0Q9SbEVFZrld2UF4e/XwD8XNpNQkiwiHM8CEvq5ddWUPhhJHzAeXhbGOv/YguzOTc1vt9oV9voogs0srLOu6pOOAmm5NnkrWD+C+M3FpVly5ynh6CK6IMghLwHj0N/wDU1zK3fPQ4LcFDrJdFL71TKH+6xzrJaL6oWCtbKradNaXYgvHvBWPc69/zjFt21ViurFhNvRV/GItEwQz+X35IjdpH9REcQOWSw/zQgdWz 1NQq8g1m SaCwsUZVODUHi673doL4oZyLltCygzi38Kq+Kod0MmW330qe+rEQhisMApEfxhYytfObscl+BrdgsmpoA9nbU237Opd4ByCQ5HEphA1XKl1jzTy/i6Tob9B63KjUp8cXnqlgPaKq2Y9BisCLSD/j8uMp0P4xhg+odO/cZmETujpD7MrWsvRe2ompmuoWfHx0lONArjkPaIHgU7xn4nhgycK8L9YrFvH/62zRXWewENuSKj/b6o93XFr5Ba5VONyTBRrHxTvuzqmujXTCZSUNuWMPebGHZ9fVU8IthxSCaMR/nVOqysfwvVbkU99uu0o7qlXQruJSYHMzqp4WkAjF/D8YkcVOp0UFJHtEPrsdCY449bYCEd+zWyuxElT3ehqionwQFFmBiDJHAsW3G9AvWN2VXHGHUJYYGtChB6oih7NCFK8I= 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 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