mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Vincent Mailhol <mailhol@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Kees Cook <kees@kernel.org>
Subject: Re: [PATCH v2 1/2] lib/ucs2_string.c: fix out-of-bounds read in ucs2_strnlen()
Date: Fri, 24 Jul 2026 10:34:48 +0200	[thread overview]
Message-ID: <2026072427-sushi-grief-29ee@gregkh> (raw)
In-Reply-To: <e7327736-219c-4475-84db-a25a25d1ec1d@kernel.org>

On Fri, Jul 24, 2026 at 08:59:02AM +0200, Vincent Mailhol wrote:
> On 24/07/2026 at 07:54, Greg KH wrote:
> > 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?
> 
> I had a similar feeling and didn't CC stable on the v1. But following
> my exchange with Andrew here:
> 
>   https://lore.kernel.org/all/CAMZ6Rq+Ax5MTs0Ke=XAB2JFX1KXuFas3B2eEMv+nQ4x7up2BLA@mail.gmail.com/
> 
> I think there *might* be some risk and finally CCed stable in v2. If
> you prefer to not backport, that's OK for me. As you can see in my
> above message, even if the risk exists, it is more theoretical and I
> don't think it would provide much leverage to turn it into a real
> exploit.

"turning into a real exploit" is not a requirement for stable backports
at all.  I was just thinking "is this even a real bug that needs to be
changed at all" given the lifetime of this issue, and the location from
where these strings come from (i.e. firmware images).

But yes, from a logical "this code should not be doing this" it does
seem correct to make.  Maybe someday we'll even be able to drop these
extra string functions entirely as we already have ways to convert from
utf16 to utf8 in the kernel already, so maybe we should just "normalize"
them all to start with after read from the firmware?

thanks,

greg k-h

  reply	other threads:[~2026-07-24  8:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 19:40 [PATCH v2 0/2] " Vincent Mailhol
2026-07-23 19:40 ` [PATCH v2 1/2] " Vincent Mailhol
2026-07-24  5:54   ` Greg KH
2026-07-24  6:59     ` Vincent Mailhol
2026-07-24  8:34       ` Greg KH [this message]
2026-07-23 19:40 ` [PATCH v2 2/2] lib/ucs2_string.c: fix indentation Vincent Mailhol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026072427-sushi-grief-29ee@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®