* [LTP] [PATCH] userfaultfd: Use two-step handshake to probe features
@ 2026-04-11 9:24 Ricardo Branco
2026-04-11 9:46 ` [LTP] " acervesato
2026-04-11 10:39 ` acervesato
0 siblings, 2 replies; 3+ messages in thread
From: Ricardo Branco @ 2026-04-11 9:24 UTC (permalink / raw)
To: ltp
userfaultfd05 and userfaultfd06 assume that
UFFD_FEATURE_PAGEFAULT_FLAG_WP and UFFD_FEATURE_POISON are available
when setting up userfaultfd.
On kernels where either feature is unavailable at runtime,
UFFDIO_API fails with EINVAL and the tests end up as TBROK instead of
being skipped.
Fix this by using the required two-step handshake and skip with TCONF
if the required feature bit is absent.
Also remove userfaultfd05's needs_kconfigs check, since runtime
feature probing is sufficient here.
Link: https://github.com/linux-test-project/ltp/issues/1289
Signed-off-by: Ricardo Branco <rbranco@suse.de>
---
testcases/kernel/syscalls/userfaultfd/userfaultfd05.c | 11 +++++++----
testcases/kernel/syscalls/userfaultfd/userfaultfd06.c | 10 +++++++---
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
index e25a227cf..5412f12e1 100644
--- a/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
@@ -89,7 +89,14 @@ static void run(void)
set_pages();
uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
+ uffdio_api.api = UFFD_API;
+ uffdio_api.features = 0;
+ SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
+ if (!(uffdio_api.features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
+ tst_brk(TCONF, "UFFD_FEATURE_PAGEFAULT_FLAG_WP not supported");
+ SAFE_CLOSE(uffd);
+ uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
uffdio_api.api = UFFD_API;
uffdio_api.features = UFFD_FEATURE_PAGEFAULT_FLAG_WP;
@@ -124,8 +131,4 @@ static void run(void)
static struct tst_test test = {
.test_all = run,
.min_kver = "5.7",
- .needs_kconfigs = (const char *[]) {
- "CONFIG_HAVE_ARCH_USERFAULTFD_WP=y",
- NULL
- }
};
diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
index 5b1252c35..7ad682f5a 100644
--- a/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
@@ -100,15 +100,19 @@ static void run(void)
set_pages();
uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
+ uffdio_api.api = UFFD_API;
+ uffdio_api.features = 0;
+ SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
+ if (!(uffdio_api.features & UFFD_FEATURE_POISON))
+ tst_brk(TCONF, "UFFD_FEATURE_POISON not supported");
+ SAFE_CLOSE(uffd);
+ uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
uffdio_api.api = UFFD_API;
uffdio_api.features = UFFD_FEATURE_POISON;
SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
- if (!(uffdio_api.features & UFFD_FEATURE_POISON))
- tst_brk(TCONF, "UFFD_FEATURE_POISON not supported");
-
uffdio_register.range.start = (unsigned long) page;
uffdio_register.range.len = page_size;
uffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] userfaultfd: Use two-step handshake to probe features
2026-04-11 9:24 [LTP] [PATCH] userfaultfd: Use two-step handshake to probe features Ricardo Branco
@ 2026-04-11 9:46 ` acervesato
2026-04-11 10:39 ` acervesato
1 sibling, 0 replies; 3+ messages in thread
From: acervesato @ 2026-04-11 9:46 UTC (permalink / raw)
To: Ricardo Branco; +Cc: ltp
Hi Ricardo,
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.
On Sat, 11 Apr 2026 11:24:51 +0200, Ricardo Branco wrote:
> userfaultfd: Use two-step handshake to probe features
> + if (!(uffdio_api.features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
> + tst_brk(TCONF, "UFFD_FEATURE_PAGEFAULT_FLAG_WP not supported");
> + SAFE_CLOSE(uffd);
tst_brk() longjmps out of run(), so SAFE_CLOSE never executes — close uffd
before calling tst_brk(). userfaultfd05.c also has no .cleanup, so the page
mmap from set_pages() leaks too; add .cleanup = reset_pages to struct tst_test.
[...]
> + if (!(uffdio_api.features & UFFD_FEATURE_POISON))
> + tst_brk(TCONF, "UFFD_FEATURE_POISON not supported");
> + SAFE_CLOSE(uffd);
Same issue: close uffd before calling tst_brk().
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] userfaultfd: Use two-step handshake to probe features
2026-04-11 9:24 [LTP] [PATCH] userfaultfd: Use two-step handshake to probe features Ricardo Branco
2026-04-11 9:46 ` [LTP] " acervesato
@ 2026-04-11 10:39 ` acervesato
1 sibling, 0 replies; 3+ messages in thread
From: acervesato @ 2026-04-11 10:39 UTC (permalink / raw)
To: Ricardo Branco; +Cc: ltp
Hi Ricardo,
our agent completed the review of the patch.
On Sat, 11 Apr 2026 11:24:51 +0200, Ricardo Branco wrote:
> userfaultfd: Use two-step handshake to probe features
> Fix this by using the required two-step handshake and skip with TCONF
> if the required feature bit is absent.
The patch is fixing a bug (UFFDIO_API EINVAL causing TBROK instead of
TCONF); please add a Fixes: tag pointing to the commit that introduced
the incorrect single-step setup.
> Link: https://github.com/linux-test-project/ltp/issues/1289
[...]
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-11 11:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11 9:24 [LTP] [PATCH] userfaultfd: Use two-step handshake to probe features Ricardo Branco
2026-04-11 9:46 ` [LTP] " acervesato
2026-04-11 10:39 ` acervesato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox