All of lore.kernel.org
 help / color / mirror / Atom feed
* [merged mm-nonmm-stable] lib-ucs2_stringc-fix-out-of-bounds-read-in-ucs2_strnlen.patch removed from -mm tree
@ 2026-08-04  4:05 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-08-04  4:05 UTC (permalink / raw)
  To: mm-commits, stable, kees, mailhol, akpm


The quilt patch titled
     Subject: lib/ucs2_string.c: fix out-of-bounds read in ucs2_strnlen()
has been removed from the -mm tree.  Its filename was
     lib-ucs2_stringc-fix-out-of-bounds-read-in-ucs2_strnlen.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Vincent Mailhol <mailhol@kernel.org>
Subject: lib/ucs2_string.c: fix out-of-bounds read in ucs2_strnlen()
Date: Thu, 23 Jul 2026 21:40:31 +0200

Patch series "lib/ucs2_string.c: fix out-of-bounds read in
ucs2_strnlen()", v2.

This series fixes an off-by-one out-of-bounds read in ucs2_strnlen().

The first patch is the real fix, the second patch comes as a bonus and
fixes the code indentation.


This patch (of 2):

ucs2_strnlen() checks the current character before checking whether the
caller-provided maximum length has been reached.  If the input is not
NUL-terminated within that bound, the loop can read one ucs2_char_t past
the limit.

Test the length before dereferencing to prevent an off-by-one
out-of-bounds read.

Link: https://lore.kernel.org/20260723-fix-ucs2_strnlen-v2-0-9ea94e32a358@kernel.org
Link: https://lore.kernel.org/20260723-fix-ucs2_strnlen-v2-1-9ea94e32a358@kernel.org
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Vincent Mailhol <mailhol@kernel.org>
Cc: Kees Cook <kees@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/ucs2_string.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/lib/ucs2_string.c~lib-ucs2_stringc-fix-out-of-bounds-read-in-ucs2_strnlen
+++ a/lib/ucs2_string.c
@@ -8,7 +8,7 @@ ucs2_strnlen(const ucs2_char_t *s, size_
 {
         unsigned long length = 0;
 
-        while (*s++ != 0 && length < maxlength)
+	while (length < maxlength && *s++ != 0)
                 length++;
         return length;
 }
_

Patches currently in -mm which might be from mailhol@kernel.org are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-04  4:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04  4:05 [merged mm-nonmm-stable] lib-ucs2_stringc-fix-out-of-bounds-read-in-ucs2_strnlen.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.