Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3130779rdb; Tue, 6 Feb 2024 08:01:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSsE7MFj7q0NmaqXIxEgSlRvjmqLYQRrA6/SVER9D5bhTNrfvAJri9BU3z2rxeFeV4ASJd X-Received: by 2002:a05:6808:68b:b0:3bf:bf81:c700 with SMTP id k11-20020a056808068b00b003bfbf81c700mr2929048oig.16.1707235310834; Tue, 06 Feb 2024 08:01:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707235310; cv=pass; d=google.com; s=arc-20160816; b=KT8U3uX5JDaHE3Zq3HLaSTIxZuejyYhDKvnPpihyxL6r6uvVD4+d2X3yuWnu4d0U8k gh+Ej8VZ6XdKbFI0a4TdZ/JMkmb8liL+WrQoZ+5HfbPjtmK7bA2bbPL3/HC2fu0koy4L MuG2pqFo4naYSv8gXUgFbwRKqxTihn+Adqcy4FmBrqCLJ0UDre8DL1NTV9VhwW6gtTOa hMGyqLugjffYkoypgmoPfoD8+jm/5t1TLAMJWxaTjk+u0EiT3zXrIr3BhkOi+q3aIhQ7 FUXLUR4KpazwVQq80ImE2b2/qaE3rP8ke86CfWAmHE+3uBdAJqfXYS87zGDpsvMX1+IF lCxA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vEAzZD/rUh6xj/N0fpWrsrVKzT8PBTtHERAYd5rS3SY=; fh=jSubbeyi/VW5oUYqA+qXVtsjiPlhk+pYc2RgKiaf0CA=; b=pWHovNXCm9f+YJzR0ZoImv/mqfg6ut9sISN06Fof08s+qn3afFONi1JxH5XZo4Rl8s g1MrTZiczJndPcqO3KzOBU3ycE4uuPVIFuZvAlr1lZuXbVXTnQrd4OCI2Qg3jF0JcqzP Jfcs0HFO7DDJCg/Yg68x41lDck9BtopDrsJjck0IdQqndkfNIMdaktad1lahFo7zGk5w a1F9669TBkgUz/TNgT+phMkll2LNJVETALgIMOdGP6ZEX6sNEX2Qr78PKDks9/sX7lxd qbFE+EpuWKLgaTdSeF1NsIYva3mxbHozkrkKTkbWxov9vGLRhC5YSS2SB8/xADR+udtY Vj8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PV0B3eTO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55295-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUyqGGui7U7oJhcQlnWn3zmAO7GXY1oXR34RvNcSvtLQPnSxsfX20ixaJ4jX2bLiQQV9XYnWx7nyRBgx6Dpa5gL3r/2rhir215WtGbLCQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j3-20020a056808034300b003be755d9906si797956oie.32.2024.02.06.08.01.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 08:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PV0B3eTO; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-55295-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55295-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7F8C229077D for ; Tue, 6 Feb 2024 16:01:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FF9F134CF3; Tue, 6 Feb 2024 16:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PV0B3eTO" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C414134CE4; Tue, 6 Feb 2024 16:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707235293; cv=none; b=ckmQvChR15+fdLewK1QxLdz1hQEbjxBXaHrPn+1NLFbncAp0Be0oUxOxqvTiuzBhDZMVw88rREtuxk5BMF65NfBYrxMQh+3gibFE6o0Ff6nREbP+ahkZR5giFH4Rm/OUA+i4tKdm1+aL7X1CbBTWuhsP0rezI9LESdhoLdvKAL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707235293; c=relaxed/simple; bh=aRQxl0C0V0705HuiquTkhHHqPboA18NaqgotYv9rCA8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h2mEI0WOsEOiPXPLgognY8Zh6RFkqDX+qNFVO+7CLVQ03VCs+rs2Ua3ll4yHAFFyOXsykoY3AVnsZvc+IfcmJ8MBV85E2sMqchT13eS+84NGZ5HJ6RWNnCGMjzoblEmyGCiUfKZifi63Kf3C7swE/LBFIgtBZsfQx9p83BqxR5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PV0B3eTO; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E2BAC433F1; Tue, 6 Feb 2024 16:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707235291; bh=aRQxl0C0V0705HuiquTkhHHqPboA18NaqgotYv9rCA8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PV0B3eTOaNjzcvWs65Me6RDLhFj8YGByJ83V31ytWUnS8qhWSmRMRl0l5zr6Ky/HI V8VB3bU4h1IvUqAnjW+GixZAPSitutZKlnNNQsb3zhPpetctNotMxhcs+16kpERvcI QJlKVt1MUAwmmTLtRKPv+7kMaAaYKnrgHOiLqelYjBoBJh2c90qyMuKpsBQaLV4ixc x4u/dAvjHm8aNECN3GpgyoQDyFjLJi59680J1T/oC03fzuisXQvW2y2jFqQGwm715y 2X7DJSP2x6Oz8DlvjQGm4xWPmxiPaAXHidpqbvV2Qg4SWxurgjdXViSVHc8zyfhu2V +S947qR7PCFqA== Date: Tue, 6 Feb 2024 16:01:28 +0000 From: Mark Brown To: debug@rivosinc.com Cc: rick.p.edgecombe@intel.com, Szabolcs.Nagy@arm.com, kito.cheng@sifive.com, keescook@chromium.org, ajones@ventanamicro.com, paul.walmsley@sifive.com, palmer@dabbelt.com, conor.dooley@microchip.com, cleger@rivosinc.com, atishp@atishpatra.org, alex@ghiti.fr, bjorn@rivosinc.com, alexghiti@rivosinc.com, corbet@lwn.net, aou@eecs.berkeley.edu, oleg@redhat.com, akpm@linux-foundation.org, arnd@arndb.de, ebiederm@xmission.com, shuah@kernel.org, brauner@kernel.org, guoren@kernel.org, samitolvanen@google.com, evan@rivosinc.com, xiao.w.wang@intel.com, apatel@ventanamicro.com, mchitale@ventanamicro.com, waylingii@gmail.com, greentime.hu@sifive.com, heiko@sntech.de, jszhang@kernel.org, shikemeng@huaweicloud.com, david@redhat.com, charlie@rivosinc.com, panqinglin2020@iscas.ac.cn, willy@infradead.org, vincent.chen@sifive.com, andy.chiu@sifive.com, gerg@kernel.org, jeeheng.sia@starfivetech.com, mason.huo@starfivetech.com, ancientmodern4@gmail.com, mathis.salmen@matsal.de, cuiyunhui@bytedance.com, bhe@redhat.com, chenjiahao16@huawei.com, ruscur@russell.cc, bgray@linux.ibm.com, alx@kernel.org, baruch@tkos.co.il, zhangqing@loongson.cn, catalin.marinas@arm.com, revest@chromium.org, josh@joshtriplett.org, joey.gouly@arm.com, shr@devkernel.io, omosnace@redhat.com, ojeda@kernel.org, jhubbard@nvidia.com, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [RFC PATCH v1 15/28] riscv/mm: Implement map_shadow_stack() syscall Message-ID: References: <20240125062739.1339782-1-debug@rivosinc.com> <20240125062739.1339782-16-debug@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="3ywwgCSX0zhXuCNZ" Content-Disposition: inline In-Reply-To: <20240125062739.1339782-16-debug@rivosinc.com> X-Cookie: You might have mail. --3ywwgCSX0zhXuCNZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 24, 2024 at 10:21:40PM -0800, debug@rivosinc.com wrote: > As discussed extensively in the changelog for the addition of this > syscall on x86 ("x86/shstk: Introduce map_shadow_stack syscall") the > existing mmap() and madvise() syscalls do not map entirely well onto the > security requirements for guarded control stacks since they lead to > windows where memory is allocated but not yet protected or stacks which > are not properly and safely initialised. Instead a new syscall > map_shadow_stack() has been defined which allocates and initialises a > shadow stack page. While I agree that this is very well written you probably want to update the references to guarded control stacks to whatever the RISC-V term is :P > --- a/include/uapi/asm-generic/mman.h > +++ b/include/uapi/asm-generic/mman.h > @@ -19,4 +19,5 @@ > #define MCL_FUTURE 2 /* lock all future mappings */ > #define MCL_ONFAULT 4 /* lock all pages that are faulted in */ > =20 > +#define SHADOW_STACK_SET_TOKEN (1ULL << 0) /* Set up a restore token= in the shadow stack */ > #endif /* __ASM_GENERIC_MMAN_H */ For arm64 I also added a SHADOW_STACK_SET_MARKER for adding a top of stack marker, did you have any thoughts on that for RISC-V? I think x86 were considering adding it too, it'd be good if we could get things consistent. --3ywwgCSX0zhXuCNZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmXCV9cACgkQJNaLcl1U h9DovAf+LgWdOKedTbffoEJgm3iDVrzzlW/jko7UF4Sjg6Gv0ngCJGWQIzvYEk/w B/3v/8xatJ9n+VbKX606intt/LsnRYDNTB3OVDKogBCeRo6NPl26QjEqt8lQQtSa po1FZcEIfdjmxWOCphm0MYLR97sxtDs+07Y6SOdoEFyowqDP9y7VIHR4juOy0RyJ tpKpA1fORTVxP50RQT+V9GZ9zuV6FL2C5ULfahB+o6W6r/wmVlSWdsFkwdnayCKv 9DqlaPDQoklRZRy6bgUPTHyc1b6suEgg2G6Om/Pzd7Z3snoiyeDBoqMgMWOhAa1r XYbr9H4oCPUEs0ONOGZmAcXzGu7kIQ== =mDMz -----END PGP SIGNATURE----- --3ywwgCSX0zhXuCNZ--