[LTP] [PATCH] lib: tst_fd: Add kernel version check to memfd_secret
Cyril Hrubis
chrubis@suse.cz
Tue Jun 18 12:15:52 CEST 2024
Hi!
> memfd_secret is a syscall added since 5.14. On earlier kernels, tests such
> as accept03, readahead01 and splice07 that use memfd_secret fail.
> This adds a kernel version check to the tst_fd library when running tests using
> memfd_secret.
>
> Test log on linux-5.10.162/arm32 with version 20240524:
> ```
> $ ./testcases/kernel/syscalls/accept/accept03
> tst_test.c:1733: TINFO: LTP version: 20240524
> tst_test.c:1617: TINFO: Timeout per run is 0h 00m 30s
> accept03.c:58: TPASS: accept() on file : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on O_PATH file : EBADF (9)
> accept03.c:58: TPASS: accept() on directory : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on /dev/zero : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on /proc/self/maps : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on pipe read end : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on pipe write end : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on epoll : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on eventfd : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on signalfd : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on timerfd : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on pidfd : ENOTSOCK (88)
> tst_fd.c:151: TCONF: Skipping fanotify: ENOSYS (38)
> accept03.c:58: TPASS: accept() on inotify : ENOTSOCK (88)
> tst_fd.c:170: TCONF: Skipping userfaultfd: ENOSYS (38)
> accept03.c:58: TPASS: accept() on perf event : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on io uring : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on bpf map : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on fsopen : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on fspick : ENOTSOCK (88)
> accept03.c:58: TPASS: accept() on open_tree : EBADF (9)
> accept03.c:58: TPASS: accept() on memfd : ENOTSOCK (88)
> tst_test.c:1677: TBROK: Test killed by SIGILL!
This looks like a bug either in kernel or libc.
> Summary:
> passed 20
> failed 0
> broken 1
> skipped 2
> warnings 0
> ```
>
> Closed: #1145
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
> ---
> lib/tst_fd.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/lib/tst_fd.c b/lib/tst_fd.c
> index 6538a098c..53f583fa0 100644
> --- a/lib/tst_fd.c
> +++ b/lib/tst_fd.c
> @@ -255,8 +255,16 @@ static void open_memfd(struct tst_fd *fd)
>
> static void open_memfd_secret(struct tst_fd *fd)
> {
> + if ((tst_kvercmp(5, 14, 0)) < 0) {
> + tst_res(TINFO, "accept() on %s: Linux kernel version is before than v5.14", tst_fd_desc(fd));
> + errno = ENOSYS;
> + goto skip;
> + }
> +
> fd->fd = syscall(__NR_memfd_secret, 0);
> +
> if (fd->fd < 0) {
> +skip:
> tst_res(TCONF | TERRNO,
> "Skipping %s", tst_fd_desc(fd));
> }
And this looks like you are working around the bug.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list