Skip to content

Commit 1840ee2

Browse files
committed
userfaultfd05: require CONFIG_HAVE_ARCH_USERFAULTFD_WP
Kernels built without arch UFFD-WP support (CONFIG_HAVE_ARCH_USERFAULTFD_WP) can report "WP unsupported" in different ways (e.g. UFFDIO_API returns -1/EINVAL on some newer kernels, while others succeed but do not advertise UFFD_FEATURE_PAGEFAULT_FLAG_WP in the returned features mask). Rather than relying on runtime probing that varies across kernels, require CONFIG_HAVE_ARCH_USERFAULTFD_WP=y via .needs_kconfigs and use SAFE_IOCTL() for UFFDIO_API again. Follow-up: 485a4cd ("userfaultfd05: allow TCONF when UFFD-WP is unsupported") Signed-off-by: Li Wang <liwang@redhat.com> Cc: Ricardo Branco <rbranco@suse.com> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
1 parent d69695a commit 1840ee2

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

testcases/kernel/syscalls/userfaultfd/userfaultfd05.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,8 @@ static void run(void)
9292

9393
uffdio_api.api = UFFD_API;
9494
uffdio_api.features = UFFD_FEATURE_PAGEFAULT_FLAG_WP;
95-
if (ioctl(uffd, UFFDIO_API, &uffdio_api) < 0) {
96-
if (!(uffdio_api.features & UFFD_FEATURE_PAGEFAULT_FLAG_WP))
97-
tst_brk(TCONF, "UFFD write-protect unsupported");
9895

99-
tst_brk(TBROK | TERRNO, "ioctl() on userfaultfd failed");
100-
}
96+
SAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);
10197

10298
uffdio_register.range.start = (unsigned long) page;
10399
uffdio_register.range.len = page_size;
@@ -128,4 +124,8 @@ static void run(void)
128124
static struct tst_test test = {
129125
.test_all = run,
130126
.min_kver = "5.7",
127+
.needs_kconfigs = (const char *[]) {
128+
"CONFIG_HAVE_ARCH_USERFAULTFD_WP=y",
129+
NULL
130+
}
131131
};

0 commit comments

Comments
 (0)