mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
mm: fix benign off-by-one 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. Link: https://lkml.kernel.org/r/9c38dd009c17b0219889c7089d9bdde5aaf28a8e.1765449750.git.alx@kernel.org Signed-off-by: Alejandro Colomar <[email protected]> Acked-by: 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: 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:
committed by
Andrew Morton
parent
436debc9ca
commit
8118f197b7
@@ -110,7 +110,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]);
|
||||
switch (r->type) {
|
||||
case KFENCE_ERROR_OOB:
|
||||
cur += scnprintf(cur, end - cur, "BUG: KFENCE: out-of-bounds %s",
|
||||
@@ -140,7 +140,7 @@ static bool report_matches(const struct expect_report *r)
|
||||
|
||||
/* Access information */
|
||||
cur = expect[1];
|
||||
end = &expect[1][sizeof(expect[1]) - 1];
|
||||
end = ARRAY_END(expect[1]);
|
||||
|
||||
switch (r->type) {
|
||||
case KFENCE_ERROR_OOB:
|
||||
|
||||
@@ -105,7 +105,7 @@ static bool report_matches(const struct expect_report *r)
|
||||
|
||||
/* Title */
|
||||
cur = expected_header;
|
||||
end = &expected_header[sizeof(expected_header) - 1];
|
||||
end = ARRAY_END(expected_header);
|
||||
|
||||
cur += scnprintf(cur, end - cur, "BUG: KMSAN: %s", r->error_type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user