Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3037360rwb; Mon, 7 Aug 2023 07:22:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsL756VkJBaYEm5T28oAHHqgjrhdGZm/LsthHBzFI510UD5QuGCpucLW17u9gYTvQBe9/I X-Received: by 2002:a2e:3504:0:b0:2b9:f0e8:f380 with SMTP id z4-20020a2e3504000000b002b9f0e8f380mr6254691ljz.52.1691418135915; Mon, 07 Aug 2023 07:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691418135; cv=none; d=google.com; s=arc-20160816; b=k3azN3kctcbfY6zz6anZtVlxKzWvjqAKEfFR71lSnpoEhSmL8oGCT0asj1CLZH5Bc9 6IHjvEl3YlAXFfnpdfsgoqsomCyFBxFLKDx/Ty0slN0qMRl5NGch1JpOaccICUXcudsT Dqf58HQBqxB3mGi2KtS48Ffh2EZhpDiJCZmal9Y2XAY86MQkDlcXGRf4vp+Rh5c463Mu aPtS0YdtBUFoYN5GTa/2qWeUpNd6/eBYuafcxLZyqsSgmqXVdFUCw4an5DdWqXVGvUOc 3RXGfthm3PfYkPfxV+0W2YC6+dgGCD8pQMC/eImjrCTG5HT3uOlMAKBu8i1d+3eEH2k0 FJRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+YWamu0OGUJu9SW4rDoYsHDRk9aJJ07BNV8H6Irh/64=; fh=xfAWAqAfX205dWUcwbPkJ2R1puUzDBUwGB2vLSxI14c=; b=FHtJ50VerstQ05xr3/djSmkX26tASgZ8asMPF7VTAreD6eemuCSFhbV5Vp+K/1QJcs 9lf3qpUzP+u4gJ0G1Hpk3pdV2MRWb2V2383NXN+tSpUNFUUxumuG94cy7lMulTMZCdup 0bk1WSSqK0uefIoKY6qX+vTbTXawmCld6wqL3Rvf07BoOFSfKf/kJMjOgnnSV+cxTzJ7 G+ddIrjekffbJYw23AMhMp5bYEYfS40WEQdEhRNh1RXjy8zl1M0zXkJ76yQrSz4aN9x9 p/vkQvXl6Yi9wDfzgZkH6j1SVh59yFcbAnUV1oN7amk1UdJynuHXEUWy81LoSjXpy7NL tqFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rvvDU8sr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id le13-20020a170907170d00b00988afd7e58asi174402ejc.350.2023.08.07.07.21.48; Mon, 07 Aug 2023 07:22:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rvvDU8sr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233358AbjHGNAz (ORCPT + 99 others); Mon, 7 Aug 2023 09:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231728AbjHGNAy (ORCPT ); Mon, 7 Aug 2023 09:00:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 298261BC; Mon, 7 Aug 2023 06:00:53 -0700 (PDT) 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 9872D619FD; Mon, 7 Aug 2023 13:00:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31608C433C7; Mon, 7 Aug 2023 13:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691413252; bh=VIywjKfIQjCBtdbDPXYlia2uvZPXVd/riPHCXoskQic=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rvvDU8srIyUZqSC/AZn5tENk73e6b7lcMD0bggv0OZy+kdMv1wzrdao14Ek53Iiyx IRdeP2i7dHvG05GYveqesPRozZBWvPkPzVgLAPzRKehV8FG4dTBFTlwNmq6W9aAmXd TOJ2NMgyqruEmA77u2ERYj64yfya3426m3ZWoUGeog++a6pvx66c8pChwY38vz523S ChaYFX40JW+pa2BW1vXmOmq45J6hBtdc88n5UAJdNuTfAiy2eP80JJIFmiP356Yg99 NUF9YdSDWmi87A0gAAG2I/js0A4x5VYEjSB7V464D9htKF6RuocFXxnBcwe4+5gtev Hkzg/2TxLfPZA== Date: Mon, 7 Aug 2023 14:00:42 +0100 From: Mark Brown To: Szabolcs Nagy Cc: Catalin Marinas , 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 , "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 v3 21/36] arm64/mm: Implement map_shadow_stack() Message-ID: <3a077ff3-8627-4337-9b4a-6a8828eda0e7@sirena.org.uk> References: <20230731-arm64-gcs-v3-0-cddf9f980d98@kernel.org> <20230731-arm64-gcs-v3-21-cddf9f980d98@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zuyh0JKERt9z219h" Content-Disposition: inline In-Reply-To: X-Cookie: idleness, n.: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --zuyh0JKERt9z219h Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Aug 07, 2023 at 11:20:58AM +0100, Szabolcs Nagy wrote: > The 07/31/2023 14:43, Mark Brown wrote: > > +SYSCALL_DEFINE3(map_shadow_stack, unsigned long, addr, unsigned long, size, unsigned int, flags) > > +{ > > + unsigned long alloc_size; > > + unsigned long __user *cap_ptr; > > + unsigned long cap_val; > > + int ret; > > + > > + if (!system_supports_gcs()) > > + return -EOPNOTSUPP; > > + > > + if (flags) > > + return -EINVAL; > > + > > + if (addr % 16) > > + return -EINVAL; > mmap addr must be page aligned (and there is no align req on size). > i'd expect similar api here. That's not what the manual page or a quick check of the code suggest that mmap() does, they say that the kernel just takes it as a hint and chooses a nearby page boundary, though I didn't test. I'm not sure why I have that alignment check at all TBH, and to the extent it's needed I could just be 8 - this level of code doesn't really care. > > + if (size == 16 || size % 16) > > + return -EINVAL; > why %16 and not %8 ? I don't think that's needed any more - there was some stuff in an earlier version of the code but no longer. --zuyh0JKERt9z219h Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmTQ6voACgkQJNaLcl1U h9ADtwf9Hi+3Tmw6lo4OcpVr7n1Zx4xMLurjUWXhlQulr3E2yaNH/LoJepX0V/Hy cYyeMDXfa9itHkAmxF+PWpfByFW2ak1NvN+VB1ywgbz4kJFiAK11hsjQzWuiJw+s e1it4mLwr1FXHqL0ewxN4pWvkFHmoyVTtKmtIlYrR4K9Xq8KEWrEDi6x5LHrI6tk HXZ6HBESzDzzrctdnfG91f3YdpxLKuvuE1l+HEVfKlh5EqEHtTxzLT1BCDHy4ebI URGjT1qEAOxoNDbYkJaaPcVnDkFfcXuSC07xv57tktihM+MnQCtZd0b+IH9lf6Ry E10gfnUnsEkptjykMZVkmRiHM0iWvQ== =jbyG -----END PGP SIGNATURE----- --zuyh0JKERt9z219h--