Thread (56 messages) 56 messages, 2 authors, 10d ago

[PATCH 20/27] selftests/landlock: Fix the snprintf() error check in matches_log_fs_extra()

flat view
COOLING10d

From: Günther Noack <hidden>
Date: 2026-10-08 14:27:38
Also in: linux-kselftest, lkml
Subsystem: kernel selftest framework, landlock security module, the rest · Maintainers: Shuah Khan, Shuah Khan, Mickaël Salaün, Linus Torvalds

By storing the snprintf result in a size_t, the chunk_len < 0 check
could never be true.  Store it in an int instead, matching the return
type of snprintf().

Fixes: 316d06b01130 ("selftests/landlock: Add audit tests for filesystem")
Assisted-by: LLM
Signed-off-by: Günther Noack <redacted>
---
 tools/testing/selftests/landlock/fs_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 9abc2adef79d..90f63af1d64d 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -7453,7 +7453,7 @@ static int matches_log_fs_extra(struct __test_metadata *const _metadata,
 				     (extra ? strlen(extra) : 0) + 1;
 	char log_match[log_match_remaining];
 	char *log_match_cursor = log_match;
-	size_t chunk_len;
+	int chunk_len;
 	ssize_t escaped_len;
 
 	chunk_len = snprintf(log_match_cursor, log_match_remaining,
-- 
2.56.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help