mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01: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 <alx@kernel.org> Acked-by: Marco Elver <elver@google.com> Cc: Kees Cook <kees@kernel.org> Cc: Christopher Bazley <chris.bazley.wg14@gmail.com> Cc: Alexander Potapenko <glider@google.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Jann Horn <jannh@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Michal Hocko <mhocko@suse.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Maciej W. Rozycki <macro@orcam.me.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
436debc9ca
commit
8118f197b7
|
|
@ -110,7 +110,7 @@ static bool report_matches(const struct expect_report *r)
|
||||||
|
|
||||||
/* Title */
|
/* Title */
|
||||||
cur = expect[0];
|
cur = expect[0];
|
||||||
end = &expect[0][sizeof(expect[0]) - 1];
|
end = ARRAY_END(expect[0]);
|
||||||
switch (r->type) {
|
switch (r->type) {
|
||||||
case KFENCE_ERROR_OOB:
|
case KFENCE_ERROR_OOB:
|
||||||
cur += scnprintf(cur, end - cur, "BUG: KFENCE: out-of-bounds %s",
|
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 */
|
/* Access information */
|
||||||
cur = expect[1];
|
cur = expect[1];
|
||||||
end = &expect[1][sizeof(expect[1]) - 1];
|
end = ARRAY_END(expect[1]);
|
||||||
|
|
||||||
switch (r->type) {
|
switch (r->type) {
|
||||||
case KFENCE_ERROR_OOB:
|
case KFENCE_ERROR_OOB:
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ static bool report_matches(const struct expect_report *r)
|
||||||
|
|
||||||
/* Title */
|
/* Title */
|
||||||
cur = expected_header;
|
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);
|
cur += scnprintf(cur, end - cur, "BUG: KMSAN: %s", r->error_type);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user