[LTP] userfaultfd: Add tests for UFFDIO_RWPROTECT and UFFDIO_SET_MODE

Ricardo Branco rbranco@suse.de
Sun Oct 25 09:35:23 CET 2026



On 10/24/26 10:22 PM, linuxtestproject.agent@gmail.com wrote:
> Hi Ricardo,
>
> On 24 Oct 2026, Ricardo Branco wrote:
>> userfaultfd: Add tests for UFFDIO_RWPROTECT and UFFDIO_SET_MODE
>> +++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd08.c
>> +	CHECK_UFFD_FEATURE(UFFD_FEATURE_RWP);
>> +	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
>> +++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd09.c
>> +	CHECK_UFFD_FEATURE(UFFD_FEATURE_RWP);
>> +	CHECK_UFFD_FEATURE(UFFD_FEATURE_RWP_ASYNC);
>> +	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
> Medium: With vm.unprivileged_userfaultfd=0 and no CAP_SYS_PTRACE, both
> tests report TCONF even when RWP is supported, because CHECK_UFFD_FEATURE()
> and run() request kernel-fault-capable descriptors.
> These tests only need userspace faults; use UFFD_USER_MODE_ONLY or enable
> the existing EPERM retry in both the feature probe and test descriptor
> creation.
>
> Verdict - Needs revision

   This is intentional. The existing userfaultfd tests (userfaultfd01-07)
   all create the fd with retry=false and TCONF in this configuration, so
   the new tests behave the same way.

   Enabling the retry in the shared check_uffd_feature() was tried in an
   earlier revision and dropped. On Linux 5.2-5.10, without
   CAP_SYS_PTRACE, the retry adds UFFD_USER_MODE_ONLY, which that kernel
   doesn't support. The call then fails with EINVAL, so the test reports
   TBROK instead of TCONF. That would also regress the existing callers.

   Handling unprivileged userfaultfd properly across all the tests would
   be a separate change to the shared helper, and doesn't belong in this
   series.




More information about the ltp mailing list