]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/landlock: Explicitly disable audit in teardowns
authorMaximilian Heyne <mheyne@amazon.de>
Fri, 29 May 2026 20:03:41 +0000 (20:03 +0000)
committerMickaël Salaün <mic@digikod.net>
Sat, 13 Jun 2026 21:15:03 +0000 (23:15 +0200)
commit0302cd72fe196aee933e3fb76f6d175d1ab0e843
tree9c6b1fed80a1ea531f86e566a0ff0ef8a693d19b
parent76579d09beedaffe7fe76e9c05644f73983e1ceb
selftests/landlock: Explicitly disable audit in teardowns

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.

Cc: stable@vger.kernel.org
Fixes: 6a500b22971c ("selftests/landlock: Add tests for audit flags and domain IDs")
Signed-off-by: Maximilian Heyne <mheyne@amazon.de>
Link: https://patch.msgid.link/20260529-welsh-nagoya-b4d9ca60@mheyne-amazon
[mic: Fix FD leak, update subject, call audit_cleanup() in audit_exec teardown]
Signed-off-by: Mickaël Salaün <mic@digikod.net>
tools/testing/selftests/landlock/audit.h
tools/testing/selftests/landlock/audit_test.c