FAILED: patch "[PATCH] selftests/landlock: Explicitly disable audit in teardowns" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x 0302cd72fe196aee933e3fb76f6d175d1ab0e843
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071614-nicotine-satisfied-6d1a@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0302cd72fe196aee933e3fb76f6d175d1ab0e843 Mon Sep 17 00:00:00 2001
From: Maximilian Heyne <[email protected]>
Date: Fri, 29 May 2026 20:03:41 +0000
Subject: [PATCH] selftests/landlock: Explicitly disable audit in teardowns
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
I'm seeing sporadic selftest failures, such as
# RUN scoped_audit.connect_to_child ...
# scoped_abstract_unix_test.c:314:connect_to_child:Expected 0 (0) == records.access (8) # connect_to_child: Test failed
# FAIL scoped_audit.connect_to_child
not ok 19 scoped_audit.connect_to_child
This seems similar to what commit 3647a4977fb73d ("selftests/landlock:
Drain stale audit records on init") tried to fix. However, the added drain loop is not effective. When setting the AUDIT_STATUS_PID, the kauditd_thread is woken up starting to send messages from the hold queue to the netlink. Depending on scheduling of this kthread not all messages might be send via the netlink in the 1 us interval.
Therefore, instead of trying to drain the queue, let's just disable audit when running non-audit tests or more precisely disable it after audit-tests. This way we won't generate any new audit message that could interfere with the other tests.
The comment saying that on process exit audit will be disabled is wrong. The closed file descriptor just causes an auditd_reset(), not a disablement. So future messages will be queued in the hold queue.
tools/testing/selftests/landlock/audit.h +8 -13
@@ -553,10 +553,9 @@ static int audit_init_filter_exe(struct audit_filter *filter, const char *path)static int audit_cleanup (int audit_fd,struct audit_filter *filter) {struct audit_filter new_filter; +int err =0 ;if (audit_fd <0 || !filter) { -int err; -/* * Simulates audit_init_with_exe_filter() when called from * FIXTURE_TEARDOWN_PARENT().
@@ -567,23 +566,19 @@ static int audit_cleanup(int audit_fd, struct audit_filter *filter) filter = &new_filter; err =audit_init_filter_exe (filter,NULL ); -if (err) { -close (audit_fd); -return err; - } +if (err) + goto err_close; }/* Filters might not be in place. */ audit_filter_exe (audit_fd, filter,AUDIT_DEL_RULE );audit_filter_drop (audit_fd,AUDIT_DEL_RULE ); -/* -* Because audit_cleanup() might not be called by the test auditd -* process, it might not be possible to explicitly set it. Anyway, -* AUDIT_STATUS_ENABLED will implicitly be set to 0 when the auditd -* process will exit. -*/ -return close (audit_fd); + err =audit_set_status (audit_fd,AUDIT_STATUS_ENABLED ,0 ); + +err_close: +close (audit_fd); +return err; }static int audit_init_with_exe_filter (struct audit_filter *filter)
tools/testing/selftests/landlock/audit_test.c +1 -3
@@ -850,10 +850,8 @@ FIXTURE_SETUP(audit_exec)FIXTURE_TEARDOWN (audit_exec) {set_cap (_metadata,CAP_AUDIT_CONTROL ); -EXPECT_EQ (0 ,audit_filter_exe (self->audit_fd, &self->audit_filter, -AUDIT_DEL_RULE )); +EXPECT_EQ (0 ,audit_cleanup (self->audit_fd, &self->audit_filter));clear_cap (_metadata,CAP_AUDIT_CONTROL ); -EXPECT_EQ (0 ,close (self->audit_fd)); }TEST_F (audit_exec, signal_and_open)