On Mon, Oct 19, 2026 at 09:03:12AM +0800, Ning, Hongyu wrote:
> Commit 3c58f641e813 ("userfaultfd: prevent registration of special
> VMAs") prevents userfaultfd registration on shadow stack VMAs to avoid
> bypassing shadow stack protections through UFFDIO_COPY.
>
> The existing shadow stack selftest still expects UFFDIO_REGISTER to
> succeed and uses UFFDIO_COPY to populate the shadow stack. This causes
> the selftest to fail on Kernels containing this security fix.
>
> Update the selftest to verify that UFFDIO_REGISTER rejects shadow stack
> VMAs with EINVAL. Remove the obsolete userfaultfd fault handling thread
> and UFFDIO_COPY test path.
>
> Tested on: Intel shadow stack capable x86_64 platform
>
> Before fix:
> [FAIL] Userfaultfd test with return code 1
>
> After fix:
> [OK] Userfaultfd rejects shadow stack registration (EINVAL)
>
> Fixes: 3c58f641e813 ("userfaultfd: prevent registration of special VMAs")
>
> Signed-off-by: Hongyu Ning <[email protected]>
Acked-by: Mike Rapoport (Microsoft) <[email protected]>
> ChatGPT was used to assist with root-cause analysis and patch
> preparation. The changes were reviewed and validated on Intel shadow
> stack capable x86_64 platform, with all 12 shadow stack tests passing.
> ---
> .../testing/selftests/x86/test_shadow_stack.c | 105 ++++++------------
> 1 file changed, 34 insertions(+), 71 deletions(-)
--
Sincerely yours,
Mike.