public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Wei Gao via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v6] listmount04.c: Update case support mnt_id_req.mnt_ns_fd
Date: Sun, 14 Dec 2025 02:15:20 +0000	[thread overview]
Message-ID: <20251214021541.3256-1-wegao@suse.com> (raw)
In-Reply-To: <20251212115244.2027-1-wegao@suse.com>

Kernel change from v6.18-rc7 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                                  |  2 +-
 include/lapi/mount.h                          | 10 +++--
 .../kernel/syscalls/listmount/listmount.h     |  2 +-
 .../kernel/syscalls/listmount/listmount04.c   | 37 +++++++++++++++++--
 .../kernel/syscalls/statmount/statmount.h     |  2 +-
 5 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0480f46ca..a0ebbb34d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -262,7 +262,7 @@ AC_CHECK_TYPES([struct cachestat_range],,,[#include <sys/mman.h>])
 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/include/lapi/mount.h b/include/lapi/mount.h
index 0f7bb5e43..3b296fc9c 100644
--- a/include/lapi/mount.h
+++ b/include/lapi/mount.h
@@ -45,14 +45,18 @@
 # define MS_NOSYMFOLLOW 256
 #endif
 
-#ifndef HAVE_STRUCT_MNT_ID_REQ
-struct mnt_id_req {
+struct mnt_id_req_fallback {
 	uint32_t size;
-	uint32_t spare;
+	uint32_t mnt_ns_fd;
 	uint64_t mnt_id;
 	uint64_t param;
 	uint64_t mnt_ns_id;
 };
+
+#ifndef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
+typedef struct mnt_id_req_fallback mnt_id_req;
+#else
+typedef struct mnt_id_req mnt_id_req;
 #endif
 
 #ifndef HAVE_STRUCT_STATMOUNT
diff --git a/testcases/kernel/syscalls/listmount/listmount.h b/testcases/kernel/syscalls/listmount/listmount.h
index aad927f71..e7ef375d7 100644
--- a/testcases/kernel/syscalls/listmount/listmount.h
+++ b/testcases/kernel/syscalls/listmount/listmount.h
@@ -15,7 +15,7 @@
 static inline ssize_t listmount(uint64_t mnt_id, uint64_t last_mnt_id,
 			 uint64_t list[], size_t num, unsigned int flags)
 {
-	struct mnt_id_req req = {
+	mnt_id_req req = {
 		.size = MNT_ID_REQ_SIZE_VER0,
 		.mnt_id = mnt_id,
 		.param = last_mnt_id,
diff --git a/testcases/kernel/syscalls/listmount/listmount04.c b/testcases/kernel/syscalls/listmount/listmount04.c
index a6921a249..c1f00d99a 100644
--- a/testcases/kernel/syscalls/listmount/listmount04.c
+++ b/testcases/kernel/syscalls/listmount/listmount04.c
@@ -14,14 +14,18 @@
 
 #define _GNU_SOURCE
 
+#include "config.h"
 #include "tst_test.h"
 #include "lapi/mount.h"
 #include "lapi/syscalls.h"
 
 #define MNT_SIZE 32
+#define BEFORE_6_18 1
+#define AFTER_6_18 2
 
-static struct mnt_id_req *request;
+static mnt_id_req *request;
 static uint64_t mnt_ids[MNT_SIZE];
+static int kver;
 
 static struct tcase {
 	int req_usage;
@@ -34,6 +38,7 @@ static struct tcase {
 	uint64_t flags;
 	int exp_errno;
 	char *msg;
+	int kver;
 } tcases[] = {
 	{
 		.req_usage = 0,
@@ -79,6 +84,18 @@ static struct tcase {
 		.nr_mnt_ids = MNT_SIZE,
 		.exp_errno = EINVAL,
 		.msg = "invalid mnt_id_req.spare",
+		.kver = BEFORE_6_18,
+	},
+	{
+		.req_usage = 1,
+		.size = MNT_ID_REQ_SIZE_VER0,
+		.spare = -1,
+		.mnt_id = LSMT_ROOT,
+		.mnt_ids = mnt_ids,
+		.nr_mnt_ids = MNT_SIZE,
+		.exp_errno = EBADF,
+		.msg = "invalid mnt_id_req.mnt_ns_fd",
+		.kver = AFTER_6_18,
 	},
 	{
 		.req_usage = 1,
@@ -113,7 +130,12 @@ static struct tcase {
 static void run(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
-	struct mnt_id_req *req = NULL;
+	mnt_id_req *req = NULL;
+
+	if (tc->kver && tc->kver != kver) {
+		tst_res(TCONF, "Skip the case that is not suitable for the current kernel version");
+		return;
+	}
 
 	memset(mnt_ids, 0, sizeof(mnt_ids));
 
@@ -122,7 +144,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->spare;
 	}
 
 	TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
@@ -130,8 +152,17 @@ static void run(unsigned int n)
 		"%s", tc->msg);
 }
 
+static void setup(void)
+{
+	if (tst_kvercmp(6, 18, 0) >= 0)
+		kver = AFTER_6_18;
+	else
+		kver = BEFORE_6_18;
+}
+
 static struct tst_test test = {
 	.test = run,
+	.setup = setup,
 	.tcnt = ARRAY_SIZE(tcases),
 	.min_kver = "6.11",
 	.bufs = (struct tst_buffers []) {
diff --git a/testcases/kernel/syscalls/statmount/statmount.h b/testcases/kernel/syscalls/statmount/statmount.h
index d21d7f8da..4217a82d8 100644
--- a/testcases/kernel/syscalls/statmount/statmount.h
+++ b/testcases/kernel/syscalls/statmount/statmount.h
@@ -16,7 +16,7 @@
 static inline int statmount(uint64_t mnt_id, uint64_t mask, struct statmount *buf,
 		     size_t bufsize, unsigned int flags)
 {
-	struct mnt_id_req req = {
+	mnt_id_req req = {
 		.size = MNT_ID_REQ_SIZE_VER0,
 		.mnt_id = mnt_id,
 		.param = mask,
-- 
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2025-12-14  2:16 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 14:39 [LTP] [PATCH v1] listmount04.c: Update case support mnt_id_req.mnt_ns_fd Wei Gao via ltp
2025-11-28  3:26 ` Li Wang via ltp
2025-11-28  7:37   ` Wei Gao via ltp
2025-12-08 11:51     ` Petr Vorel
2025-12-09  0:50       ` Wei Gao via ltp
2025-12-09  0:41 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-12-09 11:17   ` Petr Vorel
2025-12-09 15:53     ` Cyril Hrubis
2025-12-09 17:49       ` Petr Vorel
2025-12-10  6:19   ` [LTP] [PATCH v3] " Wei Gao via ltp
2025-12-10  8:38     ` Petr Vorel
2025-12-11  1:59     ` [LTP] [PATCH v4] " Wei Gao via ltp
2025-12-11  9:25       ` Cyril Hrubis
2025-12-11 11:51         ` Petr Vorel
2025-12-12 11:50       ` [LTP] [PATCH v5] " Wei Gao via ltp
2025-12-12 12:28         ` Petr Vorel
2025-12-12 12:56           ` Cyril Hrubis
2025-12-12 14:20             ` Petr Vorel
2025-12-12 15:11               ` Petr Vorel
2025-12-14  1:54                 ` Wei Gao via ltp
2025-12-15 15:22                   ` Petr Vorel
2025-12-14  2:15         ` Wei Gao via ltp [this message]
2025-12-15 15:20           ` [LTP] [PATCH v6] " Petr Vorel
2025-12-16  8:08           ` Li Wang via ltp
2025-12-17  9:32           ` Cyril Hrubis
2025-12-17 13:15             ` Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251214021541.3256-1-wegao@suse.com \
    --to=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox