mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Muhammad Bilal <meatuni001@gmail.com>
Cc: jorge.lopez2@hp.com, Hans de Goede <hansg@kernel.org>,
	 linux@weissschuh.net, platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH 2/2] platform/x86: hp-bioscfg: fix heap OOB read and buffer desync in hp_get_string_from_buffer()
Date: Mon, 21 Sep 2026 17:29:38 +0300 (EEST)	[thread overview]
Message-ID: <ab2078e1-4388-6311-0363-afdfc131ea60@linux.intel.com> (raw)
In-Reply-To: <CADqcGBnGHd+rRn6b=eWVjhWDU-NQ4CFb-3B9cgwBeouN-sbw4Q@mail.gmail.com>

On Sat, 19 Sep 2026, Muhammad Bilal wrote:

> Confirmed, you're right about the redundancy.
> 
> utf16s_to_utf8s() takes src by value, so it can't advance the caller's
> src pointer. The second loop then restarts from the same position and
> overwrites everything the conversion just wrote, using dst[i] = *src,
> a raw truncating cast with no UTF-8 encoding. So step 2 is currently
> dead work, and the function is ASCII-only in practice: any character
> above 0x7f gets truncated to garbage instead of being properly
> encoded.
> 
> Two ways to fix that, and I'd like your preference before I send
> anything more for it:
> 
> (a) Keep utf16s_to_utf8s() as the real conversion, and rewrite the
> second loop to do escaping as a pass over its UTF-8 output instead of
> re-deriving from UTF-16 src.

Not exactly this, but somewhere there.

You should not try to build the escaping nor utf-8 parsing/length 
calculation within the driver but use generic code for that.

To give some directions...

There seems to be some escaping function in lib/string_helpers.c but since 
we're dealing with an UTF-8 string here, there might not be a readily 
available function for string inputs/outputs.

escape_space() seems to also cover escaping \v, which wasn't among the 
characters this driver escapes. You might need to check that particular 
character in driver before calling the library's escape funtion though 
I'm more thinking along the lines of not escaping it was an oversight from 
the original submitter (given the questionable quality of this driver to 
begin with).

utf8clen() seems to exists, but is currently in inconvinient place (and 
already duplicated so it should be placed into some header anyway).

> (b) Drop utf16s_to_utf8s() entirely if ASCII-only was always the
> intent, and keep only the manual loop, fixing its bounds instead..

I think ASCII only was not the intent, but it just happens to work in 
many cases which is why this has survived so far.

-- 
 i.


  reply	other threads:[~2026-09-21 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 22:56 [PATCH 0/2] platform/x86: hp-bioscfg: fix OOB reads and buffer desynchronization in buffer parsers Muhammad Bilal
2026-08-24 22:56 ` [PATCH 1/2] platform/x86: hp-bioscfg: fix OOB read in hp_get_integer_from_buffer() on unaligned input Muhammad Bilal
2026-09-18 13:54   ` Ilpo Järvinen
2026-08-24 22:56 ` [PATCH 2/2] platform/x86: hp-bioscfg: fix heap OOB read and buffer desync in hp_get_string_from_buffer() Muhammad Bilal
2026-09-18 14:17   ` Ilpo Järvinen
2026-09-19  5:56     ` Muhammad Bilal
2026-09-21 14:29       ` Ilpo Järvinen [this message]
2026-09-22 11:09         ` Muhammad Bilal
2026-09-22 11:51           ` Ilpo Järvinen

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=ab2078e1-4388-6311-0363-afdfc131ea60@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=jorge.lopez2@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=meatuni001@gmail.com \
    --cc=platform-driver-x86@vger.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®