[LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD
Wake Liu
wakel@google.com
Wed Apr 29 11:48:02 CEST 2026
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
More information about the ltp
mailing list