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 B1E65C38A02 for ; Fri, 28 Oct 2022 17:03:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43A936B0071; Fri, 28 Oct 2022 13:03:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EB5F6B0073; Fri, 28 Oct 2022 13:03:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D9926B0074; Fri, 28 Oct 2022 13:03:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1A4F56B0071 for ; Fri, 28 Oct 2022 13:03:28 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id E336441326 for ; Fri, 28 Oct 2022 17:03:27 +0000 (UTC) X-FDA: 80070979254.02.CEABCF8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id F01F11C004D for ; Fri, 28 Oct 2022 17:03:26 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E3461629B9; Fri, 28 Oct 2022 17:03:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A243C43470; Fri, 28 Oct 2022 17:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666976605; bh=AESbGu2O9nYA4AXjyXIcYcJonR0BCyEzgYXDLmNxIps=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EBd7GTG/T+ApefryC1LXKWunIBdq6MOYwUDQzzRntsz16ikxQ/8PPTJ4kNV/Sjh/N dGdJwK6Fdsi3prf3uX9ShXTKBvywxbZ5Cp3h4lkh///D369bK1Un4bpcDNDU3dpSV2 yGJ9hwbKOxDaeQFuvY/h8e82yKaUnL+tSl8QWUm4jguglIYwAoZ6rjt5YD59oIoLqk hWsiykenAXk8fJ4APkKhdE51Qz9hjNQh7ShdRT1mV9WMUvmhB2cJjB1LycYGCJnAiX KJ7Gv9UdPTJfkDoWTuCB7Pq2XSxhyQL0/9FfT5tQb37PqXJeavRbQ6WJduukyq36Kv s8bqiHnLZmsZQ== Date: Fri, 28 Oct 2022 18:03:18 +0100 From: Mark Brown To: Joey Gouly Cc: Catalin Marinas , Andrew Morton , Lennart Poettering , Zbigniew =?utf-8?Q?J=C4=99drzejewski-Szmek?= , Alexander Viro , Kees Cook , Szabolcs Nagy , Jeremy Linton , Topi Miettinen , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-abi-devel@lists.sourceforge.net, nd@arm.com, shuah@kernel.org Subject: Re: [PATCH v1 2/2] kselftest: vm: add tests for memory-deny-write-execute Message-ID: References: <20221026150457.36957-1-joey.gouly@arm.com> <20221026150457.36957-3-joey.gouly@arm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="47yTjnBUJpUNKiR4" Content-Disposition: inline In-Reply-To: <20221026150457.36957-3-joey.gouly@arm.com> X-Cookie: Life -- Love It or Leave It. ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666976607; 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:dkim-signature; bh=Fkd7+PAPz2NurayBm07qiPm30/A7dik1IjnupASTgMQ=; b=FwlPHf1zPbK3abIyI6nCRoSSmK63ejmUZoVdqnB9MfrEduFStBsVuyYhxfB5Fm7BZUmFO1 ZNsX6BVATQ5b/F27kvJrHTlFi6fLfFOfNkt0YnA1+NZWeCML0IzfCRbuA9YFLMAGo0YGLV o39I4/BoDczcpRw7PXD9f6qfEl+MmvM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="EBd7GTG/"; spf=pass (imf20.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666976607; a=rsa-sha256; cv=none; b=49ukIwcXxXBIHoAtJ2rIP1sTjOl1zuGETjworLfTWHxtVuJWla/ttTgGtTz82rMu3kF0qd 2mf7in/ev/wCJdWQ//044FWetlVK0b3i5nMo0jSOjViaSDT1mH2rFQbLCvkwEH3q53Vo1x axCi/nTZymFKdqM7Je3lP4h/6nCp9VE= X-Stat-Signature: u7awbzyh44r961fewhckfjrp99wa9q1x X-Rspamd-Queue-Id: F01F11C004D Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="EBd7GTG/"; spf=pass (imf20.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1666976606-479051 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: --47yTjnBUJpUNKiR4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 26, 2022 at 04:04:57PM +0100, Joey Gouly wrote: > Add some tests to cover the new PR_SET_MDWE prctl. Some comments below but they're all stylistic and let's not make perfect be the enemy of the good here so Reviewed-by: Mark Brown and we can iterate later rather than blocking anything on the testcase. > +#ifdef __aarch64__ > +#define PROT_BTI 0x10 /* BTI guarded page */ > +#endif We should get this from the kernel headers shouldn't we? We generally rely on things getting pulled in from there rather than locally defining. > +#define TEST1 "mmap(PROT_WRITE | PROT_EXEC)\n" > +#define TEST2 "mmap(PROT_WRITE); mprotect(PROT_EXEC)\n" > +#define TEST3 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_READ)\n" > +#define TEST4 "mmap(PROT_EXEC); mprotect(PROT_EXEC | PROT_BTI)\n" > +int test1(int mdwe_enabled) > +{ It feels like we could usefully make an array of struct test { int (*run)(bool mdwe_enabled); char *name; } then we'd need fewer ifdefs, things could be more usefully named and it'd be a bit easier to add new cases. > +#ifdef __aarch64__ > + ksft_set_plan(12); > +#else > + ksft_set_plan(9); > +#endif That'd just be ksft_test_plan(3 * ARRAY_SIZE(tests). > + // First run the tests without MDWE > + test_result(test1(0), TEST1); > + test_result(test2(0), TEST2); > + test_result(test3(0), TEST3); > +#ifdef __aarch64__ > + test_result(test4(0), TEST4); > +#endif and these calls to the tests would all be iterating over the array. --47yTjnBUJpUNKiR4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmNcC1UACgkQJNaLcl1U h9C19Af/eppp5itiJzGKSzYvLeXnNUreLYh2Rqu3UnGDus4O3osH56VEL/v7GS3S ZXS7XLRRMCvqQLOdyfYMl/D0NZ81bZC4/ieqdBvCIpkl2+NQp/msNrd1Yw4zXcwM L4QjgI5rsbWq7WXkfwI8RpQqpjI0HuVZWfuGXjfPS7WBf491CheGDpw6UjKGtkKV G6moVtc6nwANL1zyshVc/HbgiwQYlmtV66UrInc9kcOWlBQXWaAGLzNqNMKhwYeo nFHG7tCGbCRhs+77IZE+XdhYyDXsf6Kwv9vgir3tUFj/4Z6lUYF+fpHIOKNp8d76 0xbl/MwaAfiZNa7VxJ2lgGgRsr+XPQ== =H3Al -----END PGP SIGNATURE----- --47yTjnBUJpUNKiR4--