kernel: fix off-by-one benign bugs

We were wasting a byte due to an off-by-one bug.  s[c]nprintf() doesn't
write more than $2 bytes including the null byte, so trying to pass
'size-1' there is wasting one byte.

This is essentially the same as the previous commit, in a different
file.

Link: https://lkml.kernel.org/r/b4a945a4d40b7104364244f616eb9fb9f1fa691f.1765449750.git.alx@kernel.org
Signed-off-by: Alejandro Colomar <[email protected]>
Cc: Marco Elver <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Christopher Bazley <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Rasmus Villemoes <[email protected]>
Cc: Marco Elver <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Maciej W. Rozycki <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
This commit is contained in:
Alejandro Colomar
2026-01-20 19:44:19 -08:00
committed by Andrew Morton
parent 8118f197b7
commit a9e5620c9a
+2 -2
View File
@@ -176,7 +176,7 @@ static bool __report_matches(const struct expect_report *r)
/* Title */
cur = expect[0];
end = &expect[0][sizeof(expect[0]) - 1];
end = ARRAY_END(expect[0]);
cur += scnprintf(cur, end - cur, "BUG: KCSAN: %s in ",
is_assert ? "assert: race" : "data-race");
if (r->access[1].fn) {
@@ -200,7 +200,7 @@ static bool __report_matches(const struct expect_report *r)
/* Access 1 */
cur = expect[1];
end = &expect[1][sizeof(expect[1]) - 1];
end = ARRAY_END(expect[1]);
if (!r->access[1].fn)
cur += scnprintf(cur, end - cur, "race at unknown origin, with ");