Re: [PATCH v6 37/41] selftests/x86: Add shadow stack test

From: Kees Cook
Date: Sun Feb 19 2023 - 15:47:26 EST


On Sat, Feb 18, 2023 at 01:14:29PM -0800, Rick Edgecombe wrote:
> Add a simple selftest for exercising some shadow stack behavior:
> - map_shadow_stack syscall and pivot
> - Faulting in shadow stack memory
> - Handling shadow stack violations
> - GUP of shadow stack memory
> - mprotect() of shadow stack memory
> - Userfaultfd on shadow stack memory
>
> Since this test exercises a recently added syscall manually, it needs
> to find the automatically created __NR_foo defines. Per the selftest
> documentation, KHDR_INCLUDES can be used to help the selftest Makefile's
> find the headers from the kernel source. This way the new selftest can
> be built inside the kernel source tree without installing the headers
> to the system. So also add KHDR_INCLUDES as described in the selftest
> docs, to facilitate this.
>
> Tested-by: Pengfei Xu <pengfei.xu@xxxxxxxxx>
> Tested-by: John Allen <john.allen@xxxxxxx>
> Co-developed-by: Yu-cheng Yu <yu-cheng.yu@xxxxxxxxx>
> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@xxxxxxxxx>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>

I'll get some test hardware and run this myself too, but overall,
ignoring the lack of kselftest_harness.h, it looks good:

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook