* [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
@ 2026-04-29 6:40 Wake Liu via ltp
2026-04-29 6:52 ` Andrea Cervesato via ltp
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Wake Liu via ltp @ 2026-04-29 6:40 UTC (permalink / raw)
To: ltp; +Cc: Wake Liu, camann, rbranco
When CONFIG_USERFAULTFD is not enabled in the kernel, the userfaultfd
syscall returns ENOSYS. Currently, SAFE_USERFAULTFD calls tst_brk(TBROK)
for any error other than EPERM, causing tests to fail when they should
be skipped.
Add a check for ENOSYS to return TCONF, so that tests using
SAFE_USERFAULTFD are skipped appropriately on kernels without
userfaultfd support.
Signed-off-by: Wake Liu <wakel@google.com>
---
include/lapi/userfaultfd.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
index 0c9e34c84..09126d856 100644
--- a/include/lapi/userfaultfd.h
+++ b/include/lapi/userfaultfd.h
@@ -244,6 +244,10 @@ static inline int safe_userfaultfd(const char *file, const int lineno, int
retry:
ret = tst_syscall(__NR_userfaultfd, flags);
if (ret == -1) {
+ if (errno == ENOSYS) {
+ tst_brk_(file, lineno, TCONF | TERRNO,
+ "userfaultfd() is not supported by this kernel");
+ }
if (errno == EPERM) {
if (retry && !(flags & UFFD_USER_MODE_ONLY)) {
flags |= UFFD_USER_MODE_ONLY;
--
2.54.0.545.g6539524ca2-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 6:40 [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD Wake Liu via ltp
@ 2026-04-29 6:52 ` Andrea Cervesato via ltp
2026-04-29 8:51 ` Wake Liu via ltp
2026-04-29 7:31 ` [LTP] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD linuxtestproject.agent
2026-04-29 11:07 ` [LTP] [PATCH] " Cyril Hrubis
2 siblings, 1 reply; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-04-29 6:52 UTC (permalink / raw)
To: Wake Liu via ltp; +Cc: camann, Wake Liu, rbranco, ltp
Hi Wake,
> When CONFIG_USERFAULTFD is not enabled in the kernel, the userfaultfd
> syscall returns ENOSYS. Currently, SAFE_USERFAULTFD calls tst_brk(TBROK)
> for any error other than EPERM, causing tests to fail when they should
> be skipped.
>
> Add a check for ENOSYS to return TCONF, so that tests using
> SAFE_USERFAULTFD are skipped appropriately on kernels without
> userfaultfd support.
>
> Signed-off-by: Wake Liu <wakel@google.com>
> ---
> include/lapi/userfaultfd.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
> index 0c9e34c84..09126d856 100644
> --- a/include/lapi/userfaultfd.h
> +++ b/include/lapi/userfaultfd.h
> @@ -244,6 +244,10 @@ static inline int safe_userfaultfd(const char *file, const int lineno, int
> retry:
> ret = tst_syscall(__NR_userfaultfd, flags);
> if (ret == -1) {
> + if (errno == ENOSYS) {
This is already handled in the tst_syscall() implementation.
The solution would be to use:
static struct tst_test test = {
..
.needs_kconfigs = (const char *[]) {
"CONFIG_USERFAULTFD=y",
NULL
}
};
for all the tests which need this configuration.
Where did you see this issue? Do you have a use case scenario where
this happened?
Kind regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 6:52 ` Andrea Cervesato via ltp
@ 2026-04-29 8:51 ` Wake Liu via ltp
2026-04-29 9:22 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 13+ messages in thread
From: Wake Liu via ltp @ 2026-04-29 8:51 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: camann, rbranco, Wake Liu via ltp
I encountered this issue during Android GKI (Generic Kernel Image) and
VTS (Vendor Test Suite) testing on various device targets (e.g., Pixel
6, virtual devices). In our testing environment, we run the same test
suite against a wide variety of kernel versions and configurations.
Specifically, on some kernels where CONFIG_USERFAULTFD is disabled,
the userfaultfd() syscall returns ENOSYS. While you mentioned
tst_syscall() handles it, in the version/configuration we are using,
tst_syscall() returns -1 and sets errno to ENOSYS. This is then passed
to safe_userfaultfd(), which currently only checks for EPERM to skip
(TCONF) and falls back to TBROK for any other error, including ENOSYS.
Andrea Cervesato <andrea.cervesato@suse.com> 於 2026年4月29日週三 下午2:52寫道:
>
> Hi Wake,
>
> > When CONFIG_USERFAULTFD is not enabled in the kernel, the userfaultfd
> > syscall returns ENOSYS. Currently, SAFE_USERFAULTFD calls tst_brk(TBROK)
> > for any error other than EPERM, causing tests to fail when they should
> > be skipped.
> >
> > Add a check for ENOSYS to return TCONF, so that tests using
> > SAFE_USERFAULTFD are skipped appropriately on kernels without
> > userfaultfd support.
> >
> > Signed-off-by: Wake Liu <wakel@google.com>
> > ---
> > include/lapi/userfaultfd.h | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
> > index 0c9e34c84..09126d856 100644
> > --- a/include/lapi/userfaultfd.h
> > +++ b/include/lapi/userfaultfd.h
> > @@ -244,6 +244,10 @@ static inline int safe_userfaultfd(const char *file, const int lineno, int
> > retry:
> > ret = tst_syscall(__NR_userfaultfd, flags);
> > if (ret == -1) {
> > + if (errno == ENOSYS) {
>
> This is already handled in the tst_syscall() implementation.
> The solution would be to use:
>
> static struct tst_test test = {
> ..
> .needs_kconfigs = (const char *[]) {
> "CONFIG_USERFAULTFD=y",
> NULL
> }
> };
>
> for all the tests which need this configuration.
>
> Where did you see this issue? Do you have a use case scenario where
> this happened?
>
> Kind regards,
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
--
Best Regards,
Wake Liu
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 8:51 ` Wake Liu via ltp
@ 2026-04-29 9:22 ` Andrea Cervesato via ltp
2026-04-29 9:48 ` Wake Liu via ltp
0 siblings, 1 reply; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-04-29 9:22 UTC (permalink / raw)
To: Wake Liu; +Cc: camann, rbranco, Wake Liu via ltp
> I encountered this issue during Android GKI (Generic Kernel Image) and
> VTS (Vendor Test Suite) testing on various device targets (e.g., Pixel
> 6, virtual devices). In our testing environment, we run the same test
> suite against a wide variety of kernel versions and configurations.
>
> Specifically, on some kernels where CONFIG_USERFAULTFD is disabled,
> the userfaultfd() syscall returns ENOSYS. While you mentioned
> tst_syscall() handles it, in the version/configuration we are using,
> tst_syscall() returns -1 and sets errno to ENOSYS. This is then passed
> to safe_userfaultfd(), which currently only checks for EPERM to skip
> (TCONF) and falls back to TBROK for any other error, including ENOSYS.
I'm a bit puzzled because according to the tst_syscall() implementation
this should not happen. If syscall returns -1 with errno == ENOSYS,
the tst_syscall() implementation will always TCONF. This is visible
in include/lapi/syscalls.h generated by the build system before
compiling.
Please provide the exact test that is failing, as well as the logs
you have seen having this issue.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 9:22 ` Andrea Cervesato via ltp
@ 2026-04-29 9:48 ` Wake Liu via ltp
2026-04-29 10:02 ` Andrea Cervesato via ltp
0 siblings, 1 reply; 13+ messages in thread
From: Wake Liu via ltp @ 2026-04-29 9:48 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: rbranco, Wake Liu via ltp
Thank you for your reply and for pointing out the behavior of tst_syscall().
I must apologize for the confusion. You are absolutely correct
that tst_syscall() automatically handles ENOSYS and
returns TCONF. I assumed it was ENOSYS without looking closely at
the exact error code in the logs.
After checking the logs again, I found that in our Android GKI
testing environment (kernel 6.12.74-android16), the
userfaultfd() syscall actually returns EOPNOTSUPP (95) instead of
ENOSYS when CONFIG_USERFAULTFD is disabled.
Here is the relevant log snippet for userfaultfd04:
external/ltp/testcases/kernel/syscalls/userfaultfd/userfaultfd04.c:73:
TBROK: syscall(__NR_userfaultfd, 526336)
failed: EOPNOTSUPP (95)
Because the error was EOPNOTSUPP, the TCONF logic in tst_syscall()
(which only checks for ENOSYS) was bypassed, and
the error fell through to safe_userfaultfd(). Since
safe_userfaultfd() only handles EPERM for TCONF and defaults to
TBROK for everything else, it resulted in the TBROK failure.
Given this behavior, I think we should update the patch to handle
EOPNOTSUPP in safe_userfaultfd() as well (and maybe
keep ENOSYS just in case other kernels do return it).
What do you think about this? I would be happy to send a v2 patch
addressing this.
Andrea Cervesato <andrea.cervesato@suse.com> 於 2026年4月29日週三 下午5:22寫道:
>
> > I encountered this issue during Android GKI (Generic Kernel Image) and
> > VTS (Vendor Test Suite) testing on various device targets (e.g., Pixel
> > 6, virtual devices). In our testing environment, we run the same test
> > suite against a wide variety of kernel versions and configurations.
> >
> > Specifically, on some kernels where CONFIG_USERFAULTFD is disabled,
> > the userfaultfd() syscall returns ENOSYS. While you mentioned
> > tst_syscall() handles it, in the version/configuration we are using,
> > tst_syscall() returns -1 and sets errno to ENOSYS. This is then passed
> > to safe_userfaultfd(), which currently only checks for EPERM to skip
> > (TCONF) and falls back to TBROK for any other error, including ENOSYS.
>
> I'm a bit puzzled because according to the tst_syscall() implementation
> this should not happen. If syscall returns -1 with errno == ENOSYS,
> the tst_syscall() implementation will always TCONF. This is visible
> in include/lapi/syscalls.h generated by the build system before
> compiling.
>
> Please provide the exact test that is failing, as well as the logs
> you have seen having this issue.
>
> Regards,
> --
> Andrea Cervesato
> SUSE QE Automation Engineer Linux
> andrea.cervesato@suse.com
--
Best Regards,
Wake Liu
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 9:48 ` Wake Liu via ltp
@ 2026-04-29 10:02 ` Andrea Cervesato via ltp
2026-04-29 10:12 ` [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y Wake Liu via ltp
0 siblings, 1 reply; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-04-29 10:02 UTC (permalink / raw)
To: Wake Liu; +Cc: rbranco, Wake Liu via ltp
> What do you think about this? I would be happy to send a v2 patch
> addressing this.
>
no everything makes more sense :-) the right way to handle this issue
is to use needs_kconfig as I explained in the first email.
Feel free to follow that pattern after trying it out. It should work.
Kind regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y
2026-04-29 10:02 ` Andrea Cervesato via ltp
@ 2026-04-29 10:12 ` Wake Liu via ltp
2026-04-29 12:22 ` [LTP] " linuxtestproject.agent
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Wake Liu via ltp @ 2026-04-29 10:12 UTC (permalink / raw)
To: ltp; +Cc: Wake Liu, camann, rbranco
The test fails with TBROK on systems where CONFIG_USERFAULTFD is not
enabled because SAFE_USERFAULTFD calls tst_syscall(__NR_userfaultfd)
which fails (e.g., returning ENOSYS or EOPNOTSUPP), and SAFE_USERFAULTFD
calls tst_brk(TBROK) for errors other than EPERM.
Fix this by adding CONFIG_USERFAULTFD=y to .needs_kconfigs, so that
the test is skipped with TCONF on kernels without userfaultfd support.
Signed-off-by: Wake Liu <wakel@google.com>
---
testcases/kernel/syscalls/userfaultfd/userfaultfd04.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testcases/kernel/syscalls/userfaultfd/userfaultfd04.c b/testcases/kernel/syscalls/userfaultfd/userfaultfd04.c
index 4eb811e45..a84117964 100644
--- a/testcases/kernel/syscalls/userfaultfd/userfaultfd04.c
+++ b/testcases/kernel/syscalls/userfaultfd/userfaultfd04.c
@@ -98,4 +98,8 @@ static void run(void)
static struct tst_test test = {
.test_all = run,
+ .needs_kconfigs = (const char *[]) {
+ "CONFIG_USERFAULTFD=y",
+ NULL
+ }
};
--
2.54.0.545.g6539524ca2-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [LTP] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y
2026-04-29 10:12 ` [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y Wake Liu via ltp
@ 2026-04-29 12:22 ` linuxtestproject.agent
2026-05-06 15:52 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-05-06 15:57 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 13+ messages in thread
From: linuxtestproject.agent @ 2026-04-29 12:22 UTC (permalink / raw)
To: Wake Liu; +Cc: ltp, LTP AI Reviewer
Hi Wake,
On 2026-04-29, Wake Liu wrote:
> syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y
> + .needs_kconfigs = (const char *[]) {
> + "CONFIG_USERFAULTFD=y",
> + NULL
> + }
Reviewed-by: LTP AI Reviewer <ltp-ai@noreply.github.com>
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/25108331937
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y
2026-04-29 10:12 ` [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y Wake Liu via ltp
2026-04-29 12:22 ` [LTP] " linuxtestproject.agent
@ 2026-05-06 15:52 ` Andrea Cervesato via ltp
2026-05-06 15:57 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-05-06 15:52 UTC (permalink / raw)
To: Wake Liu; +Cc: rbranco, Wake Liu, camann, ltp
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y
2026-04-29 10:12 ` [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y Wake Liu via ltp
2026-04-29 12:22 ` [LTP] " linuxtestproject.agent
2026-05-06 15:52 ` [LTP] [PATCH] " Andrea Cervesato via ltp
@ 2026-05-06 15:57 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 13+ messages in thread
From: Andrea Cervesato via ltp @ 2026-05-06 15:57 UTC (permalink / raw)
To: Wake Liu; +Cc: rbranco, Wake Liu, camann, ltp
Merged, Thanks!
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [LTP] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 6:40 [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD Wake Liu via ltp
2026-04-29 6:52 ` Andrea Cervesato via ltp
@ 2026-04-29 7:31 ` linuxtestproject.agent
2026-04-29 7:36 ` Andrea Cervesato via ltp
2026-04-29 11:07 ` [LTP] [PATCH] " Cyril Hrubis
2 siblings, 1 reply; 13+ messages in thread
From: linuxtestproject.agent @ 2026-04-29 7:31 UTC (permalink / raw)
To: Wake Liu; +Cc: ltp
Hi Wake,
On Wed, 29 Apr 2026 14:40:10 +0800, Wake Liu wrote:
> lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
> + if (errno == ENOSYS) {
> + tst_brk_(file, lineno, TCONF | TERRNO,
> + "userfaultfd() is not supported by this kernel");
> + }
The fix is correct, but since this is a bug fix, please add a Fixes:
tag pointing to the commit that introduced SAFE_USERFAULTFD without
ENOSYS handling.
---
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
2026-04-29 6:40 [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD Wake Liu via ltp
2026-04-29 6:52 ` Andrea Cervesato via ltp
2026-04-29 7:31 ` [LTP] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD linuxtestproject.agent
@ 2026-04-29 11:07 ` Cyril Hrubis
2 siblings, 0 replies; 13+ messages in thread
From: Cyril Hrubis @ 2026-04-29 11:07 UTC (permalink / raw)
To: Wake Liu; +Cc: camann, rbranco, ltp
Hi!
> include/lapi/userfaultfd.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/lapi/userfaultfd.h b/include/lapi/userfaultfd.h
> index 0c9e34c84..09126d856 100644
> --- a/include/lapi/userfaultfd.h
> +++ b/include/lapi/userfaultfd.h
> @@ -244,6 +244,10 @@ static inline int safe_userfaultfd(const char *file, const int lineno, int
> retry:
> ret = tst_syscall(__NR_userfaultfd, flags);
> if (ret == -1) {
> + if (errno == ENOSYS) {
> + tst_brk_(file, lineno, TCONF | TERRNO,
> + "userfaultfd() is not supported by this kernel");
> + }
The tst_syscall() code has already branch that checks for ENOSYS and
calls tst_brk(TCONF, ...) which looks like:
#define TST_SYSCALL_BRK__(NR, SNR) ({ \
tst_brk(TCONF, \
"syscall(%d) " SNR " not supported on your arch", NR); \
})
#define tst_syscall(NR, ...) ({ \
intptr_t tst_ret; \
if (NR == __LTP__NR_INVALID_SYSCALL) { \
errno = ENOSYS; \
tst_ret = -1; \
} else { \
tst_ret = syscall(NR, ##__VA_ARGS__); \
} \
if (tst_ret == -1 && errno == ENOSYS) { \
TST_SYSCALL_BRK__(NR, #NR); \
} \
tst_ret; \
})
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2026-05-06 15:58 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 6:40 [LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD Wake Liu via ltp
2026-04-29 6:52 ` Andrea Cervesato via ltp
2026-04-29 8:51 ` Wake Liu via ltp
2026-04-29 9:22 ` Andrea Cervesato via ltp
2026-04-29 9:48 ` Wake Liu via ltp
2026-04-29 10:02 ` Andrea Cervesato via ltp
2026-04-29 10:12 ` [LTP] [PATCH] syscalls/userfaultfd04: Require CONFIG_USERFAULTFD=y Wake Liu via ltp
2026-04-29 12:22 ` [LTP] " linuxtestproject.agent
2026-05-06 15:52 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-05-06 15:57 ` Andrea Cervesato via ltp
2026-04-29 7:31 ` [LTP] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD linuxtestproject.agent
2026-04-29 7:36 ` Andrea Cervesato via ltp
2026-04-29 11:07 ` [LTP] [PATCH] " Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox