[LTP] userfaultfd: Minor fixes

linuxtestproject.agent@gmail.com linuxtestproject.agent@gmail.com
Tue May 5 19:32:20 CEST 2026


Hi Ricardo,

On Tue, 5 May 2026 15:14:41 +0200, Ricardo Branco wrote:
> userfaultfd: Minor fixes
>
> - Use POSIX semantics for thread function
> - Set cleanup to call reset_pages
> - Use long for page_size and use unsigned cast
> - Call the SAFE_ versions of some system calls
> - Use TFAIL consistently for unexpected UFFD_EVENTs

The body only lists what was changed, not why. Please add at least a
sentence per item explaining the problem: e.g. the thread function had
the wrong signature (UB when cast to pthread start routine), missing
.cleanup caused leaks on early abort, int page_size causes sign-extension
in the bitwise address mask, etc.

> -static void *handle_thread(void)
> +static void *handle_thread(void *arg LTP_ATTRIBUTE_UNUSED)
>
> -       tst_brk(TBROK | TERRNO, "Received unexpected UFFD_EVENT %d", msg.event);
> +       tst_brk(TFAIL, "Received unexpected UFFD_EVENT %d", msg.event);
>
> -       page_size = sysconf(_SC_PAGE_SIZE);
> +       page_size = SAFE_SYSCONF(_SC_PAGE_SIZE);
> +       .cleanup = reset_pages,

These are five distinct fix categories (thread signature, resource
management, type correctness, SAFE-macro adoption, result-code change).
Please split them into focused commits so each can be reviewed and
bisected independently.

Pre-existing issues noticed in the surrounding code (not introduced
by this patch):

- userfaultfd04.c (and similar): early-return TFAIL path skips
  SAFE_PTHREAD_JOIN, leaving the handler thread un-joined.
- userfaultfd03.c: .needs_root = 1 may be unnecessary since
  /dev/userfaultfd was designed for unprivileged access.

---
Note:

Our agent completed the review of the patch.

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