[LTP] [PATCH] lib: tst_fd: Add kernel version check to memfd_secret

Cyril Hrubis chrubis@suse.cz
Fri Jun 21 11:05:53 CEST 2024


Hi!
> I would suggest using tst_syscall() to check for syscall undefined instead
> of this modification. How about this modification? 
> 
> ```
> --- a/lib/tst_fd.c
> +++ b/lib/tst_fd.c
> @@ -255,7 +255,8 @@ static void open_memfd(struct tst_fd *fd)
> 
>  static void open_memfd_secret(struct tst_fd *fd)
>  {
> -       fd->fd = syscall(__NR_memfd_secret, 0);
> +       fd->fd = tst_syscall(__NR_memfd_secret, 0);
>         if (fd->fd < 0) {
>                 tst_res(TCONF | TERRNO,
>                         "Skipping %s", tst_fd_desc(fd));
> ```

We cannot use tst_syscall() in the tst_fd library because it calls
tst_brk() with TCONF which exits the test immediately, but in this case
we actually want to continue with the rest of the tests.

I guess that the best fix is to add fallback definitions for
memfd_secret into include/lapi/syscalls/*.in files. That way we should
get -1 and EINVAL properly even when kernel does not support the
syscall.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list