* [LTP] [PATCH] landlock04: Skip variants unsupported by the running Landlock ABI
@ 2026-07-06 1:37 Ivan Hu via ltp
2026-07-06 5:14 ` [LTP] " linuxtestproject.agent
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ivan Hu via ltp @ 2026-07-06 1:37 UTC (permalink / raw)
To: ltp
The LANDLOCK_ACCESS_FS_TRUNCATE access right is only available from
Landlock ABI v3 (kernel v6.2, commit b9f5ce27c8f8 "landlock: Support
file truncation"). On older kernels (e.g. those exposing ABI v1) setup()
passed the variant's access right, including LANDLOCK_ACCESS_FS_TRUNCATE,
directly to landlock_add_rule(), which failed with EINVAL and broke the
test:
landlock04.c: TBROK: landlock_add_rule(8, 1, ..., 0): EINVAL (22)
tester_get_all_fs_rules() already masks the rule set according to the
running kernel's Landlock ABI. Use it in setup() to detect when a variant
requires an unsupported access right and skip it with TCONF instead of
breaking.
Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
testcases/kernel/syscalls/landlock/landlock04.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/landlock/landlock04.c b/testcases/kernel/syscalls/landlock/landlock04.c
index 737fdbf24..86dc19994 100644
--- a/testcases/kernel/syscalls/landlock/landlock04.c
+++ b/testcases/kernel/syscalls/landlock/landlock04.c
@@ -143,12 +143,26 @@ static void enable_exec_libs(const int ruleset_fd)
static void setup(void)
{
struct tvariant variant = tvariants[tst_variant];
+ int supported_rules;
verify_landlock_is_enabled();
tst_res(TINFO, "Testing %s", variant.desc);
- ruleset_attr->handled_access_fs = tester_get_all_fs_rules();
+ supported_rules = tester_get_all_fs_rules();
+
+ /* Some access rights are only available from a given Landlock ABI
+ * version (e.g. LANDLOCK_ACCESS_FS_TRUNCATE needs ABI >= 3). Skip the
+ * variant when the running kernel doesn't support the tested right,
+ * otherwise landlock_add_rule() fails with EINVAL.
+ */
+ if (variant.access & ~supported_rules) {
+ tst_brk(TCONF,
+ "%s is not supported by the current Landlock ABI",
+ variant.desc);
+ }
+
+ ruleset_attr->handled_access_fs = supported_rules;
ruleset_fd = SAFE_LANDLOCK_CREATE_RULESET(
ruleset_attr, sizeof(struct tst_landlock_ruleset_attr_abi1), 0);
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-06 8:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 1:37 [LTP] [PATCH] landlock04: Skip variants unsupported by the running Landlock ABI Ivan Hu via ltp
2026-07-06 5:14 ` [LTP] " linuxtestproject.agent
2026-07-06 7:57 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-07-06 8:03 ` Andrea Cervesato via ltp
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.