Skip to content

Commit a9e5620

Browse files
alejandro-colomarakpm00
authored andcommitted
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]>
1 parent 8118f19 commit a9e5620

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

kernel/kcsan/kcsan_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static bool __report_matches(const struct expect_report *r)
176176

177177
/* Title */
178178
cur = expect[0];
179-
end = &expect[0][sizeof(expect[0]) - 1];
179+
end = ARRAY_END(expect[0]);
180180
cur += scnprintf(cur, end - cur, "BUG: KCSAN: %s in ",
181181
is_assert ? "assert: race" : "data-race");
182182
if (r->access[1].fn) {
@@ -200,7 +200,7 @@ static bool __report_matches(const struct expect_report *r)
200200

201201
/* Access 1 */
202202
cur = expect[1];
203-
end = &expect[1][sizeof(expect[1]) - 1];
203+
end = ARRAY_END(expect[1]);
204204
if (!r->access[1].fn)
205205
cur += scnprintf(cur, end - cur, "race at unknown origin, with ");
206206

0 commit comments

Comments
 (0)