From: Ricardo Branco <rbranco@suse.de>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 2/3] userfaultfd: Use two-step handshake to probe features
Date: Thu, 7 May 2026 14:28:54 +0200 [thread overview]
Message-ID: <20260507122858.19670-2-rbranco@suse.de> (raw)
In-Reply-To: <20260507122858.19670-1-rbranco@suse.de>
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.
Fixes: 1840ee23d172b5ab04cca7c2acfa48755b041911
Link: https://github.com/linux-test-project/ltp/issues/1289
Signed-off-by: Ricardo Branco <rbranco@suse.de>
---
testcases/kernel/syscalls/userfaultfd/userfaultfd05.c | 8 +++++++-
testcases/kernel/syscalls/userfaultfd/userfaultfd06.c | 6 +++---
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
index 59956d85d..a42ac09bd 100644
--- a/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd05.c
@@ -22,6 +22,11 @@ static char *page;
static int uffd = -1;
static volatile int wp_fault_seen;
+static void setup(void)
+{
+ CHECK_UFFD_FEATURE(UFFD_FEATURE_PAGEFAULT_FLAG_WP);
+}
+
static void set_pages(void)
{
page_size = SAFE_SYSCONF(_SC_PAGE_SIZE);
@@ -87,7 +92,7 @@ static void *handle_thread(void *arg LTP_ATTRIBUTE_UNUSED)
static void run(void)
{
pthread_t thr;
- struct uffdio_api uffdio_api;
+ struct uffdio_api uffdio_api = {};
struct uffdio_register uffdio_register;
struct uffdio_writeprotect uffdio_writeprotect;
@@ -127,6 +132,7 @@ static void run(void)
}
static struct tst_test test = {
+ .setup = setup,
.test_all = run,
.min_kver = "5.7",
.needs_kconfigs = (const char *[]) {
diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
index ec93d8ad6..1ab288e64 100644
--- a/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd06.c
@@ -38,6 +38,8 @@ static void setup(void)
{
struct sigaction sa = {};
+ CHECK_UFFD_FEATURE(UFFD_FEATURE_POISON);
+
sa.sa_handler = sigbus_handler;
sigemptyset(&sa.sa_mask);
SAFE_SIGACTION(SIGBUS, &sa, NULL);
@@ -99,6 +101,7 @@ static void run(void)
poison_fault_seen = 0;
sigbus_seen = 0;
+
set_pages();
uffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, false);
@@ -108,9 +111,6 @@ static void run(void)
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.54.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-05-07 12:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 12:28 [LTP] [PATCH v4 1/3] userfaultfd: Add helper for checking UFFD feature support Ricardo Branco
2026-05-07 12:28 ` Ricardo Branco [this message]
2026-05-07 12:36 ` [LTP] [PATCH v4 2/3] userfaultfd: Use two-step handshake to probe features Andrea Cervesato via ltp
2026-05-07 12:28 ` [LTP] [PATCH v4 3/3] userfaultfd: Reset wp_fault_seen on each run() Ricardo Branco
2026-05-07 12:36 ` Andrea Cervesato via ltp
2026-05-07 12:40 ` [LTP] [PATCH v4 1/3] userfaultfd: Add helper for checking UFFD feature support Andrea Cervesato via ltp
2026-05-07 14:20 ` Cyril Hrubis
2026-05-07 14:22 ` [LTP] " linuxtestproject.agent
2026-05-07 14:40 ` Andrea Cervesato via ltp
2026-05-07 14:43 ` Cyril Hrubis
2026-05-07 16:57 ` Andrea Cervesato via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260507122858.19670-2-rbranco@suse.de \
--to=rbranco@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.