Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Alejandro Colomar and committed by
Andrew Morton
8118f197 436debc9

+3 -3
+2 -2
mm/kfence/kfence_test.c
··· 110 110 111 111 /* Title */ 112 112 cur = expect[0]; 113 - end = &expect[0][sizeof(expect[0]) - 1]; 113 + end = ARRAY_END(expect[0]); 114 114 switch (r->type) { 115 115 case KFENCE_ERROR_OOB: 116 116 cur += scnprintf(cur, end - cur, "BUG: KFENCE: out-of-bounds %s", ··· 140 140 141 141 /* Access information */ 142 142 cur = expect[1]; 143 - end = &expect[1][sizeof(expect[1]) - 1]; 143 + end = ARRAY_END(expect[1]); 144 144 145 145 switch (r->type) { 146 146 case KFENCE_ERROR_OOB:
+1 -1
mm/kmsan/kmsan_test.c
··· 105 105 106 106 /* Title */ 107 107 cur = expected_header; 108 - end = &expected_header[sizeof(expected_header) - 1]; 108 + end = ARRAY_END(expected_header); 109 109 110 110 cur += scnprintf(cur, end - cur, "BUG: KMSAN: %s", r->error_type); 111 111