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 E5D8AEE4982 for ; Fri, 18 Aug 2023 17:30:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10400940065; Fri, 18 Aug 2023 13:30:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B4CC940012; Fri, 18 Aug 2023 13:30:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBE27940065; Fri, 18 Aug 2023 13:30:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D9008940012 for ; Fri, 18 Aug 2023 13:30:04 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A2E3A140A48 for ; Fri, 18 Aug 2023 17:30:04 +0000 (UTC) X-FDA: 81137913528.29.4B698FD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id DBDB140033 for ; Fri, 18 Aug 2023 17:30:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.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=1692379803; a=rsa-sha256; cv=none; b=n7yXzbohPKMIYlm9XRgq/Fv46qyId4O7JVmtOPH1azBF592+frzkV2gJ56+aNdI/wG5Nza +Orfe0jTbdCHVx6tNHq2Qq45Plm40dcOwvbz41Zr6TYdDnFAqWz35Dg7d53V86Nc2Q5qfv StYriCGIcrKx6Nh8yCesZjudnQqwvfk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.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=1692379803; 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=97JBSgs0tb80a/singGZEAZoIvrbpKCXSTCrdl09Rz4=; b=PPP3oWnwEG+/jAPHI3zV62AtLIGVGm1GINRic+Ru8RdqJqfCblgVSTwGIxVFRO8e7eHc2R HMJO/pWl7DKhZRN8UhlZu4vS4vwZTjhr/OSUz/IMAFy1aNfVj6bRFo9R/kKtNo6p/5K38d xpOa5bnNZ/uKG7Do29SlFwMKK+gVj6U= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DF22D63FF9; Fri, 18 Aug 2023 17:30:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61717C433C7; Fri, 18 Aug 2023 17:29:56 +0000 (UTC) Date: Fri, 18 Aug 2023 18:29:54 +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 , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , 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 v4 03/36] arm64/gcs: Document the ABI for Guarded Control Stacks Message-ID: References: <20230807-arm64-gcs-v4-0-68cfa37f9069@kernel.org> <20230807-arm64-gcs-v4-3-68cfa37f9069@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DBDB140033 X-Stat-Signature: xe1znccaqwfd58a9gyxgwjdgs9hy7q9x X-HE-Tag: 1692379802-9966 X-HE-Meta: U2FsdGVkX1+ty5KVNBzGa6+V1GMoqLpDimZ3MKtGtOAlfQiGD0oEZdMkBg4EUHmN9z+AR9o5+oPC3Nqd3SDy70zY5VLaqRridyx03/Zzlot5CAA2rivmgjbXON5W73wHvmjW8BVG1KqiFANyoYUHUeVTE9wAwB2d1zU+t4kyATZ3z6/yq/y0DOrSfHMo5Wx50CVGVPh6TuXA4Gmo2UZRE9ftKHlf3cVbTHiLUr/TyoqM+7ZwAcWyD6X4guHhsMzvnAcNCrROoMYhdf5LQoDsGE9UwZ9WibVbis4Ye0r7OP29H+Tm29Qyu65oSzltUoMbkYlvMG/ZXlZYhfgOLI747DFZTiVn0Slg8vR9iru2R9vYAv5ZPuZisCy/mIrZD62I+6TOcV7WQTZXb90eyX9aA6DLOE/S6JZI+0L1YBKbsN2Qy2O7xkcydeVHHJa+VQk0LlLk8B3w/U72rHLAM66wLtcRzDkPSEckXnIfRCHFZbhC/BiTGijCpqfGpiUHa3qPE4E6u95u+r2b7ZNsOlix19EBQHNUIYwtLp8OoN4Vt/FUxho63l4Nzx25I2pnZ7WRqFh7noXDUbW66S7vXDMumoFJT8pyJSkCmkFV4CDVf+IEz1aTBNP88x2Fi+Doi9hnQJJ3VFXnvSruTFmyhbigpmyc8NQTQ6GZnHBoJ1XraeKoD/dewP2gJ1C0sEzCDebpo5qGu++jW7Xl65cmc88S559rzqdola6FkcOTPhphqXVntO2FTgCtEtXKkHG2XtvbUJ68T7vmRTMRAIAaVDHgfBMmxyFpHqQ89WHgLG/5RO7Ibvl7Ko55kNkSKy2vl6om3widTfx4/Ia4J+gevrQEmgpJ7AJQX5sIDcwru45rlOxeZnna6VaaGfZ35xusuBD54oOV7I2VeiQdb3f4AxqgaigLubTN+9W7OeDfJPzAI6xZitC6um/x8FuiRd9WoKf+SpJYxEmMtZq/+WlSM6n OYV7lmQI FhAa/ujbIa8k80qsgtsZZHrUsrGTk9H2ND7CgSoS/ldEfQuNYo+XTmyLrI01YdaEAHVaNYclQLzBNxClVxeCdQ+Gq6qBqKs3BqChxkODi/JXYZ2puTETRDRxFFJxLVzOdbFbtqon5cSCW9/JH8xGW8INnLXQx6RiuwXZ2U0ACDuZH2YhGkR3jb1WqHXLKGHmmzyvZ73SsuJ35Do3FdAYPCVp2Tf4t0EV/tXFqr3drdhkgpfiNaJBTvFjhR2+wpMILao0414af4RDu+oQZPBOj5mWN8QnIWjEFcGeeO7m4NDN4DKLdJFgKoqJfm4KbfNJT2tozGq/Yqf0sRgIxvNlciTO2O2z3mK4wJbGgIefXAjxVGMKCzihjrybkiU4nsfxZxVfiz9wq+hEuxRmEHnLhoZKt/K5s53/G0Qy8WnsQ9ye+gcMrU+JuQDSjvRmCAiRHP/lMFjFOjUGGIwAFUgy9qKS5zVBd6+f0Y5/x7r39tzoIZsI= 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: On Wed, Aug 09, 2023 at 04:34:38PM +0100, Mark Brown wrote: > On Wed, Aug 09, 2023 at 03:24:14PM +0100, Catalin Marinas wrote: > > On Mon, Aug 07, 2023 at 11:00:08PM +0100, Mark Brown wrote: > > > +* When set PR_SHADOW_STACK_ENABLE flag allocates a Guarded Control Stack for > > > > The 'for' at the end of the line above is not needed. > > > > > + and enables GCS for the thread, enabling the functionality controlled by > > I find it a little clearer that it's a per thread stack here but sure. If it reads better for you, feel free to keep it as is. > > > +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 / 2 or 2 gigabytes, whichever is > > > + smaller. > > > Is this number based on the fact that a function call would only push > > the LR to GCS while standard function prologue pushes at least two > > registers? > > It's actually based on bitrot that I'd initially chosen a smaller value > since it's likely that functions will push at least something as you > suggest, the patches now just use RLIMIT_STACK. I'll fix. A related question - it may have been discussed intensively on the x86 thread (I may read it sometime) - why not have the libc map the shadow stack and pass the pointer/size to clone3()? It saves us from having to guess what the right size we'd need. struct clone_args is extensible. (I plan to get back next week to this series, I'll need to read a bit more on the spec) -- Catalin