Thread (56 messages) 56 messages, 2 authors, 6d ago

Re: [PATCH 10/27] selftests/landlock: Assert audit initialization in fixture setups

flat view

From: sashiko-bot@kernel.org
Date: 2026-10-08 14:44:04

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests: cascading test failures due to skipped teardown on ASSERT_LE abort
--

commit 924f6036b77ebee776959fad4d5c2f2f2ab050ad
Author: Günther Noack [off-list ref]

selftests/landlock: Assert audit initialization in fixture setups

This commit replaces EXPECT_* with ASSERT_* macros for audit initialization
in Landlock tests to prevent tests from proceeding with an invalid audit
file descriptor when initialization fails.
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 9884ce9917db7..779a7bf477a95 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -7508,7 +7508,7 @@ FIXTURE_SETUP(audit_layout1)
 
 	set_cap(_metadata, CAP_AUDIT_CONTROL);
 	self->audit_fd = audit_init_with_exe_filter(&self->audit_filter);
-	EXPECT_LE(0, self->audit_fd);
+	ASSERT_LE(0, self->audit_fd);
[Severity: Medium]
Will this change cause cascading test failures when audit initialization fails?

When ASSERT_LE fails (for example, if auditd is running), it aborts the
fixture setup immediately. In kselftest_harness, this causes the child process
to exit before clearing _metadata->no_teardown.

In the parent process, the teardown wrapper checks
!__atomic_test_and_set(_metadata->no_teardown, __ATOMIC_RELAXED). Because
no_teardown remains true, the parent entirely skips FIXTURE_TEARDOWN_PARENT().

Since prepare_layout() created TMP_DIR on the host filesystem prior to the
setup failure, skipping the teardown leaks TMP_DIR.

Subsequent tests that use prepare_layout() will call
create_directory(..., TMP_DIR), which asserts that mkdir(path, 0700) == 0.
The leftover directory causes mkdir to return -1 with EEXIST, triggering
another assertion failure.

Does the teardown need to be called even if audit_init_with_exe_filter() fails,
or should we retain EXPECT_LE so the setup completes and no_teardown is cleared?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008142604.39107-2-gnoack3000@gmail.com?part=10
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help