[LTP] [PATCH v4] userfaultfd: Add tests for UFFDIO_RWPROTECT and UFFDIO_SET_MODE
Ricardo Branco
rbranco@suse.de
Wed Nov 25 22:10:22 CET 2026
On 11/25/26 1:22 PM, Cyril Hrubis wrote:
> Shouldn't this part be in else branch? Otherwise we run both tests for n
> = 1.
That's intentional. For n = 1 the thing under test is UFFDIO_SET_MODE:
after disabling RWP_ASYNC, the only way to verify the switch took effect
is to show that the next access on a re-protected page blocks and is
delivered as a fault. Without that second half we'd only be checking
that the ioctl returns 0.
> I suppose that we would have to run the handle_thread in the first if
> branch as well, but not as a thread, since it's asynchronous we can run
> it as a normal function.
With UFFD_FEATURE_RWP_ASYNC the kernel resolves the access itself and
no fault message is queued at all, so handle_thread() would block in
poll() forever. The async branch actually asserts that: after the
access it checks that poll() on the uffd with a zero timeout returns 0.
In v5 I'll split the two phases into check_async_access() and
check_sync_fault() helpers with a comment in run(), so the flow is
explicit: n = 0 runs only the sync check, n = 1 runs the async check,
then UFFDIO_SET_MODE, then the sync check.
Best,
Ricardo
More information about the ltp
mailing list