[LTP] [PATCH] syscalls/listmount04: Detect backported commit 78f0e33cd6c9 dynamically
Cyril Hrubis
chrubis@suse.cz
Wed Jun 3 11:27:03 CEST 2026
Hi!
> static void setup(void)
> {
> - if (tst_kvercmp(6, 17, 9) >= 0)
> - kver = AFTER_6_17_9;
> - else
> - kver = BEFORE_6_17_9;
> + /* 1. If kernel is 6.17.9 or newer, it definitively has the new behavior */
> + if (tst_kvercmp(6, 17, 9) >= 0) {
> + current_fd_err_behavior = INVALID_FD_RET_EBADF;
> + return;
> + }
> +
> + /* 2. Runtime probe for older kernels:
> + * Check if commit 78f0e33cd6c9 was backported by manually issuing
> + * a syscall with an invalid mnt_ns_fd (-1).
> + */
> + mnt_id_req probe_req = {
> + .size = MNT_ID_REQ_SIZE_VER0,
> + .mnt_id = LSMT_ROOT,
> + .mnt_ns_fd = -1,
> + .param = 0
> + };
> +
> + tst_syscall(__NR_listmount, &probe_req, mnt_ids, MNT_SIZE, 0);
> +
> + /* 3. Set global behavior flag based on actual kernel response */
> + if (errno == EBADF) {
> + tst_res(TINFO, "Detected backported commit 78f0e33cd6c9 (returns EBADF)");
> + current_fd_err_behavior = INVALID_FD_RET_EBADF;
> + } else {
> + current_fd_err_behavior = INVALID_FD_RET_EINVAL;
> + }
This is too complicated. I think that we want to settle for:
* new behavior after 6.17.9 (i.e. EBADF)
* any of the two errnos before that (i.e. either EINVAL or EBADF)
For that we should skip to TST_EXP_FAIL_ARR() pass array with only single
errno for all cases but the one one where we need to allow both EINVAL
and EBADF.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list