]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/landlock: Fix socket file descriptor leaks in audit helpers
authorMickaël Salaün <mic@digikod.net>
Thu, 2 Apr 2026 19:26:03 +0000 (21:26 +0200)
committerMickaël Salaün <mic@digikod.net>
Tue, 7 Apr 2026 16:51:01 +0000 (18:51 +0200)
commit9143d790337a0d066c2d632c802f69b981e6c23a
tree20be1dee4e94f4c9a5580241e289fb6d579dcb24
parentb566f7a4f0e4f15f78f2e5fac273fa954991e03a
selftests/landlock: Fix socket file descriptor leaks in audit helpers

audit_init() opens a netlink socket and configures it, but leaks the
file descriptor if audit_set_status() or setsockopt() fails.  Fix this
by jumping to an error path that closes the socket before returning.

Apply the same fix to audit_init_with_exe_filter(), which leaks the file
descriptor from audit_init() if audit_init_filter_exe() or
audit_filter_exe() fails, and to audit_cleanup(), which leaks it if
audit_init_filter_exe() fails in FIXTURE_TEARDOWN_PARENT().

Cc: Günther Noack <gnoack@google.com>
Cc: stable@vger.kernel.org
Fixes: 6a500b22971c ("selftests/landlock: Add tests for audit flags and domain IDs")
Reviewed-by: Günther Noack <gnoack3000@gmail.com>
Link: https://lore.kernel.org/r/20260402192608.1458252-3-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
tools/testing/selftests/landlock/audit.h