[LTP] [PATCH v1] listmount04.c: Update case support mnt_id_req.mnt_ns_fd
Wei Gao
wegao@suse.com
Tue Dec 9 01:50:11 CET 2025
On Mon, Dec 08, 2025 at 12:51:32PM +0100, Petr Vorel wrote:
> Hi all,
>
> first, we have a different patch increasing value to 6.11.
> https://lore.kernel.org/ltp/20251203081226.1148236-1-masahiro.yamada@canonical.com/
I guess above new change should not handled within this commit correct?
>
> > On Fri, Nov 28, 2025 at 11:26:07AM +0800, Li Wang wrote:
> > > Hi Wei,
>
>
> > > On Thu, Nov 27, 2025 at 9:41 AM Wei Gao via ltp <ltp@lists.linux.it> wrote:
>
> > > > New kernel commit lead test case failure with following error message:
> > > > listmount04.c:128: TFAIL: invalid mnt_id_req.spare expected EINVAL: EBADF
> > > > (9)
>
> > > > Detail of new kernel commit:
> > > > commit: 78f0e33cd6c939a555aa80dbed2fec6b333a7660
> > > > fs/namespace: correctly handle errors returned by grab_requested_mnt_ns
>
> > > > Signed-off-by: Wei Gao <wegao@suse.com>
> > > > ---
> > > > configure.ac | 1 +
> > > > .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------
> > > > 2 files changed, 13 insertions(+), 6 deletions(-)
>
> > > > diff --git a/configure.ac b/configure.ac
> > > > index 0480f46ca..fcff90799 100644
> > > > --- a/configure.ac
> > > > +++ b/configure.ac
> > > > @@ -263,6 +263,7 @@ AC_CHECK_TYPES([struct cachestat],,,[#include
> > > > <sys/mman.h>])
>
> > > > # Defined in <linux/mount.h>, but include/lapi/mount.h includes
> > > > <sys/mount.h> */
> > > > AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>])
> > > > +AC_CHECK_MEMBERS([struct mnt_id_req.mnt_ns_fd],,,[#include <sys/mount.h>])
> > > > AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
> > > > AC_CHECK_MEMBERS([struct statmount.mnt_ns_id],,,[#include <unistd.h>
> > > > #include <linux/mount.h>])
> > > > diff --git a/testcases/kernel/syscalls/listmount/listmount04.c
> > > > b/testcases/kernel/syscalls/listmount/listmount04.c
> > > > index a52bad064..3be3be4f2 100644
> > > > --- a/testcases/kernel/syscalls/listmount/listmount04.c
> > > > +++ b/testcases/kernel/syscalls/listmount/listmount04.c
> > > > @@ -18,6 +18,7 @@
> > > > #include "lapi/mount.h"
> > > > #include "lapi/syscalls.h"
>
> > > > +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
> > > > #define MNT_SIZE 32
>
> > > > static struct mnt_id_req *request;
> > > > @@ -26,7 +27,7 @@ static uint64_t mnt_ids[MNT_SIZE];
> > > > static struct tcase {
> > > > int req_usage;
> > > > uint32_t size;
> > > > - uint32_t spare;
> > > > + uint32_t mnt_ns_fd;
> > > > uint64_t mnt_id;
> > > > uint64_t param;
> > > > uint64_t *mnt_ids;
> > > > @@ -73,12 +74,12 @@ static struct tcase {
> > > > {
> > > > .req_usage = 1,
> > > > .size = MNT_ID_REQ_SIZE_VER0,
> > > > - .spare = -1,
> > > > + .mnt_ns_fd = -1,
> > > > .mnt_id = LSMT_ROOT,
> > > > .mnt_ids = mnt_ids,
> > > > .nr_mnt_ids = MNT_SIZE,
> > > > - .exp_errno = EINVAL,
> > > > - .msg = "invalid mnt_id_req.spare",
> > > > + .exp_errno = EBADF,
> > > > + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor",
> > > > },
> > > > {
> > > > .req_usage = 1,
> > > > @@ -122,7 +123,7 @@ static void run(unsigned int n)
> > > > req->mnt_id = tc->mnt_id;
> > > > req->param = tc->param;
> > > > req->size = tc->size;
> > > > - req->spare = tc->spare;
> > > > + req->mnt_ns_fd = tc->mnt_ns_fd;
> > > > }
>
> > > > TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
> > > > @@ -133,9 +134,14 @@ static void run(unsigned int n)
> > > > static struct tst_test test = {
> > > > .test = run,
> > > > .tcnt = ARRAY_SIZE(tcases),
> > > > - .min_kver = "6.8",
> > > > + .min_kver = "6.18",
>
>
> FYI this is a runtime check, but the problem is with kernel headers.
> include/lapi/mount.h [1] uses <sys/mount.h> (see LTP include/lapi/mount.h [1]
> and the reason why we did endup using <sys/mount.h> instead of <linux/mount.h>
> [2] [3]), but glibc (since certain version, unlike musl) includes <linux/mount.h>.
> Therefore while the problem is on current Debian testing with linux-libc-dev all
> 6.17.9-1 (it was working in previous builds with linux-libc-dev all 6.17.8-1).
> But OTOH my openSUSE Tumbleweed VM with 6.18.0-rc6-4.gfea0d97 works without this
> patch. Also SLE16 with 6.12 based kernel works without this patch.
>
> tst_test.c:2028: TINFO: Tested kernel: 6.18.0-rc6-4.gfea0d97-default #1 SMP PREEMPT_DYNAMIC Sat Nov 22 19:46:55 UTC 2025 (fea0d97) x86_64
> tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
> tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
> tst_test.c:1846: TINFO: Overall timeout per run is 0h 02m 00s
> listmount04.c:128: TPASS: request points to unaccessible memory : EFAULT (14)
> listmount04.c:128: TPASS: mnt_ids points to unaccessible memory : EFAULT (14)
> listmount04.c:128: TPASS: invalid flags : EINVAL (22)
> listmount04.c:128: TPASS: insufficient mnt_id_req.size : EINVAL (22)
> listmount04.c:128: TPASS: invalid mnt_id_req.spare : EINVAL (22)
> listmount04.c:128: TPASS: invalid mnt_id_req.param : EINVAL (22)
> listmount04.c:128: TPASS: invalid mnt_id_req.mnt_id : EINVAL (22)
> listmount04.c:128: TPASS: non-existant mnt_id : ENOENT (2)
>
> [1] https://github.com/linux-test-project/ltp/blob/master/include/lapi/mount.h
> [2] https://github.com/linux-test-project/ltp/commit/a2300dc0f51f46ffb07a465d8734639dbe3af044
> [3] https://github.com/linux-test-project/ltp/commit/1feeb57811a4aa2f56ad85edf69a8ea870867c65
>
> > > Reviewed-by: Li Wang <liwang@redhat.com>
>
> > > This patch looks good, I have one question do we need to cover the 'spare'
> > > field test for kernels between 6.8 to 6.18?
> > I think only keep tracking latest feature's change can make our life
> > easy for this case :)
>
> Due the above IMHO we should consider support for <6.11, 6.17> as well.
> We have similar crazy approach for a struct change in include/lapi/fanotify.h,
> see FSID_VAL_MEMBER().
v2 patch is sent wihtout touch min version, since another patch will
increase min version seperately.
>
> Kind regards,
> Petr
>
> > > .bufs = (struct tst_buffers []) {
> > > > { &request, .size = MNT_ID_REQ_SIZE_VER0 },
> > > > {},
> > > > },
> > > > };
> > > > +
> > > > +#else
> > > > + TST_TEST_TCONF(
> > > > + "This system does not support mnt_id_req.mnt_ns_fd.");
> > > > +#endif /* HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD */
> > > > --
> > > > 2.51.0
>
>
> > > > --
> > > > Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
>
> > > --
> > > Regards,
> > > Li Wang
More information about the ltp
mailing list