[LTP] userfaultfd: Add tests for UFFDIO_RWPROTECT and UFFDIO_SET_MODE

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Sat Oct 24 16:21:26 CEST 2026


Hi Ricardo,

On Sat, 24 Oct 2026, Ricardo Branco wrote:
> userfaultfd: Add tests for UFFDIO_RWPROTECT and UFFDIO_SET_MODE

> diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd08.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd08.c
> +	SAFE_IOCTL(uffd, UFFDIO_RWPROTECT, &uffdio_rwprotect);
> +
> +	SAFE_CLOSE(uffd);

High: Closing the last userfaultfd independently restores permissions and
wakes faulting threads, so this test can pass even if the unprotect ioctl
returns success without resolving the fault. Remove this close and let
reset_pages() close the fd after the reader resumes and the handler is
joined.

> diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd08.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd08.c
> +	CHECK_UFFD_FEATURE(UFFD_FEATURE_RWP);
> +	uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
> diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd09.c 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: Both tests skip with TCONF when vm.unprivileged_userfaultfd=0 and
CAP_SYS_PTRACE is absent, although these accesses only cause user-mode
faults. Request UFFD_USER_MODE_ONLY, or enable the existing retry, in both
run() calls and the feature probes; check_uffd_feature() currently
hard-codes retry=false too.

> diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd09.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd09.c
> +	SAFE_IOCTL(uffd, UFFDIO_SET_MODE, &uffdio_set_mode);

Medium: These are the ioctls under test, but SAFE_IOCTL accepts any
nonnegative result and reports negative results as TBROK rather than
TFAIL. Use TEST with an explicit zero-return assertion, or TST_EXP_PASS
with appropriate failure control flow, for UFFDIO_RWPROTECT and
UFFDIO_SET_MODE in both tests.

Verdict - Needs revision

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer


More information about the ltp mailing list