[LTP] [PATCH] listmount04: Allow both EINVAL and EBADF for BEFORE_6_17_9 case

Wake Liu wakel@google.com
Thu Apr 30 13:23:46 CEST 2026


On some LTS kernels (like 6.12.y or 6.6.y), the bug fix
commit 78f0e33cd6c9 ("fs/namespace: correctly handle errors returned
by grab_requested_mnt_ns") was backported.

The backport changes the behavior of listmount() for kernels
before 6.17.9, returning EBADF instead of EINVAL when invalid
mnt_id_req.spare is provided.

Update the run() function to accept both EINVAL and EBADF when the
expected errno is EINVAL on a kernel version before 6.17.9.

Change-Id: If5b138e64b7c3d8434eea180dd6adc845db44f42
Signed-off-by: Wake Liu <wakel@google.com>
---
 testcases/kernel/syscalls/listmount/listmount04.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/listmount/listmount04.c b/testcases/kernel/syscalls/listmount/listmount04.c
index 919f4c854..ee15ff99c 100644
--- a/testcases/kernel/syscalls/listmount/listmount04.c
+++ b/testcases/kernel/syscalls/listmount/listmount04.c
@@ -152,9 +152,16 @@ static void run(unsigned int n)
 		req->mnt_ns_fd = tc->spare;
 	}
 
-	TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
-		tc->nr_mnt_ids, tc->flags), tc->exp_errno,
-		"%s", tc->msg);
+	if (tc->exp_errno == EINVAL && tc->kver == BEFORE_6_17_9) {
+		int exp_errs[] = {EINVAL, EBADF};
+		TST_EXP_FAIL_ARR(tst_syscall(__NR_listmount, req, tc->mnt_ids,
+			tc->nr_mnt_ids, tc->flags), exp_errs, 2,
+			"%s", tc->msg);
+	} else {
+		TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
+			tc->nr_mnt_ids, tc->flags), tc->exp_errno,
+			"%s", tc->msg);
+	}
 }
 
 static void setup(void)
-- 
2.54.0.545.g6539524ca2-goog



More information about the ltp mailing list