Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/landlock: Fix snprintf truncation checks in audit helpers

snprintf() returns the number of characters that would have been
written, excluding the terminating NUL byte. When the output is
truncated, this return value equals or exceeds the buffer size. Fix
matches_log_domain_allocated() and matches_log_domain_deallocated() to
detect truncation with ">=" instead of ">".

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-2-mic@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>

+2 -2
+2 -2
tools/testing/selftests/landlock/audit.h
··· 309 309 310 310 log_match_len = 311 311 snprintf(log_match, sizeof(log_match), log_template, pid); 312 - if (log_match_len > sizeof(log_match)) 312 + if (log_match_len >= sizeof(log_match)) 313 313 return -E2BIG; 314 314 315 315 return audit_match_record(audit_fd, AUDIT_LANDLOCK_DOMAIN, log_match, ··· 326 326 327 327 log_match_len = snprintf(log_match, sizeof(log_match), log_template, 328 328 num_denials); 329 - if (log_match_len > sizeof(log_match)) 329 + if (log_match_len >= sizeof(log_match)) 330 330 return -E2BIG; 331 331 332 332 return audit_match_record(audit_fd, AUDIT_LANDLOCK_DOMAIN, log_match,