[LTP] [PATCH] lapi/userfaultfd: Handle ENOSYS in SAFE_USERFAULTFD

Andrea Cervesato andrea.cervesato@suse.com
Wed Apr 29 08:52:34 CEST 2026


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


More information about the ltp mailing list