From: "Mickaël Salaün" <mic@digikod.net>
To: "Günther Noack" <gnoack@google.com>
Cc: "Mickaël Salaün" <mic@digikod.net>,
linux-security-module@vger.kernel.org,
"Justin Suess" <utilityemal77@gmail.com>,
"Tingmao Wang" <m@maowtm.org>
Subject: [PATCH v3 0/5] Fix Landlock audit test flakiness
Date: Thu, 2 Apr 2026 21:26:01 +0200 [thread overview]
Message-ID: <20260402192608.1458252-1-mic@digikod.net> (raw)
This series fixes two classes of audit selftest failures plus two minor
bugs in the audit test helpers.
The main issue is that domain deallocation audit records are emitted
asynchronously from kworker threads and can arrive after a previous
test's socket has been closed. This causes two distinct failure modes:
- audit_match_record() picks up a stale deallocation record from a
previous test instead of the expected one, causing a domain ID
mismatch. The audit.layers test (which reads 16 deallocation records
in sequence) is particularly vulnerable because the large read window
allows stale records to interleave. Patch 4 fixes this by filtering
deallocation records by domain ID and skipping type-matching records
with wrong content patterns.
- audit_count_records() counts stale deallocation records from a
previous test, incrementing records.domain from the expected 0 to 1.
Patch 3 fixes this by draining stale records at audit_init() time and
removing records.domain == 0 checks that are not preceded by
audit_match_record() calls (which would consume stale records).
These races are more likely to manifest when additional instrumentation
changes kworker timing in the deallocation path (e.g. with the upcoming
Landlock tracepoints work).
The two minor fixes (patches 1-2) correct a snprintf truncation check
off-by-one and socket file descriptor leaks on error paths in
audit_init(), audit_init_with_exe_filter(), and audit_cleanup().
Patch 5 fixes a __u64 format warning reported by the kbuild bot on
powerpc64.
Patch 1 is an exact subset of the v1 combined patch, which is why it
carries the Reviewed-by tag. Patches 2 and 3 extend beyond what was in
v1, so the Reviewed-by is not carried. Patches 4 and 5 are new.
Changes since v2:
https://lore.kernel.org/r/20260401161503.1136946-1-mic@digikod.net
- Patches 4-5: fix __u64 format warnings on powerpc64 (cast to unsigned
long long for %llx). Patch 5 is new.
Changes since v1:
https://lore.kernel.org/r/20260312100444.2609563-8-mic@digikod.net
- Split the combined drain fix into four separate patches.
- Patch 2: extend fd leak fix to audit_init_with_exe_filter() and
audit_cleanup().
- Patch 3: also remove domain checks from audit.trace and
scoped_audit.connect_to_child, document constraint, explain why a
longer drain timeout was rejected.
- Patch 4: new, add domain ID filtering and timeout management to
matches_log_domain_deallocated(), skip stale records in
audit_match_record().
Mickaël Salaün (5):
selftests/landlock: Fix snprintf truncation checks in audit helpers
selftests/landlock: Fix socket file descriptor leaks in audit helpers
selftests/landlock: Drain stale audit records on init
selftests/landlock: Skip stale records in audit_match_record()
selftests/landlock: Fix format warning for __u64 in net_test
tools/testing/selftests/landlock/audit.h | 133 ++++++++++++++----
tools/testing/selftests/landlock/audit_test.c | 36 ++---
tools/testing/selftests/landlock/net_test.c | 2 +-
.../testing/selftests/landlock/ptrace_test.c | 1 -
.../landlock/scoped_abstract_unix_test.c | 1 -
5 files changed, 119 insertions(+), 54 deletions(-)
--
2.53.0
next reply other threads:[~2026-04-02 19:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 19:26 Mickaël Salaün [this message]
2026-04-02 19:26 ` [PATCH v3 1/5] selftests/landlock: Fix snprintf truncation checks in audit helpers Mickaël Salaün
2026-04-02 20:30 ` Günther Noack
2026-04-02 19:26 ` [PATCH v3 2/5] selftests/landlock: Fix socket file descriptor leaks " Mickaël Salaün
2026-04-02 20:25 ` Günther Noack
2026-04-02 19:26 ` [PATCH v3 3/5] selftests/landlock: Drain stale audit records on init Mickaël Salaün
2026-04-02 20:28 ` Günther Noack
2026-04-02 19:26 ` [PATCH v3 4/5] selftests/landlock: Skip stale records in audit_match_record() Mickaël Salaün
2026-04-02 19:26 ` [PATCH v3 5/5] selftests/landlock: Fix format warning for __u64 in net_test Mickaël Salaün
2026-04-02 20:21 ` Günther Noack
2026-04-02 20:52 ` [PATCH v3 0/5] Fix Landlock audit test flakiness Günther Noack
2026-04-02 20:57 ` Günther Noack
2026-04-03 17:08 ` Mickaël Salaün
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260402192608.1458252-1-mic@digikod.net \
--to=mic@digikod.net \
--cc=gnoack@google.com \
--cc=linux-security-module@vger.kernel.org \
--cc=m@maowtm.org \
--cc=utilityemal77@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox