From: Mark Brown <broonie@kernel.org>
To: Joey Gouly <joey.gouly@arm.com>
Cc: "Catalin Marinas" <catalin.marinas@arm.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Lennart Poettering" <lennart@poettering.net>,
"Zbigniew Jędrzejewski-Szmek" <zbyszek@in.waw.pl>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Kees Cook" <keescook@chromium.org>,
"Szabolcs Nagy" <szabolcs.nagy@arm.com>,
"Jeremy Linton" <jeremy.linton@arm.com>,
"Topi Miettinen" <toiwoton@gmail.com>,
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
Date: Fri, 28 Oct 2022 18:03:18 +0100 [thread overview]
Message-ID: <Y1wLVsg8VN26xI7j@sirena.org.uk> (raw)
In-Reply-To: <20221026150457.36957-3-joey.gouly@arm.com>
[-- Attachment #1: Type: text/plain, Size: 1513 bytes --]
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 <broonie@kernel.org>
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.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-10-28 17:03 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-26 15:04 [PATCH v1 0/2] mm: In-kernel support for memory-deny-write-execute (MDWE) Joey Gouly
2022-10-26 15:04 ` [PATCH v1 1/2] mm: Implement memory-deny-write-execute as a prctl Joey Gouly
2022-10-28 18:51 ` Kees Cook
2022-11-10 11:27 ` Joey Gouly
2022-11-10 12:03 ` Catalin Marinas
2022-11-12 6:11 ` Topi Miettinen
2022-11-15 15:35 ` Catalin Marinas
2022-11-15 19:31 ` Topi Miettinen
2022-10-26 15:04 ` [PATCH v1 2/2] kselftest: vm: add tests for memory-deny-write-execute Joey Gouly
2022-10-28 17:03 ` Mark Brown [this message]
2022-11-08 17:33 ` Joey Gouly
2022-11-09 13:33 ` Mark Brown
2022-10-28 17:45 ` Kees Cook
2022-10-28 20:16 ` Kees Cook
2022-11-07 12:23 ` Szabolcs Nagy
2022-10-28 20:19 ` Kees Cook
2022-11-06 19:42 ` [PATCH v1 0/2] mm: In-kernel support for memory-deny-write-execute (MDWE) Topi Miettinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1wLVsg8VN26xI7j@sirena.org.uk \
--to=broonie@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=jeremy.linton@arm.com \
--cc=joey.gouly@arm.com \
--cc=keescook@chromium.org \
--cc=lennart@poettering.net \
--cc=linux-abi-devel@lists.sourceforge.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nd@arm.com \
--cc=shuah@kernel.org \
--cc=szabolcs.nagy@arm.com \
--cc=toiwoton@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zbyszek@in.waw.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox