Re: [PATCH v2 1/2] lib/ucs2_string.c: fix out-of-bounds read in ucs2_strnlen()

From: Greg KH

Date: Fri Jul 24 2026 - 01:54:41 EST


On Thu, Jul 23, 2026 at 09:40:31PM +0200, Vincent Mailhol wrote:
> 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.

That's fine, but doing that read doesn't actually "hurt" anything,
right? So this shouldn't be needed in stable kernels. Or am I missing
something?

thanks,

greg k-h