* [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
* Re: [LTP] landlock04: Skip variants unsupported by the running Landlock ABI
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 ` linuxtestproject.agent
2026-07-06 7:57 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-07-06 8:03 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 4+ messages in thread
From: linuxtestproject.agent @ 2026-07-06 5:14 UTC (permalink / raw)
To: Ivan Hu; +Cc: ltp
Hi Ivan,
On Mon, 6 Jul 2026 09:37:19 +0800, Ivan Hu wrote:
> landlock04: Skip variants unsupported by the running Landlock ABI
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] landlock04: Skip variants unsupported by the running Landlock ABI
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 ` Andrea Cervesato via ltp
2026-07-06 8:03 ` Andrea Cervesato via ltp
2 siblings, 0 replies; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2026-07-06 7:57 UTC (permalink / raw)
To: Ivan Hu via ltp; +Cc: ltp
Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] landlock04: Skip variants unsupported by the running Landlock ABI
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
2 siblings, 0 replies; 4+ messages in thread
From: Andrea Cervesato via ltp @ 2026-07-06 8:03 UTC (permalink / raw)
To: Ivan Hu via ltp; +Cc: ltp
Merged, Thanks!
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [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.