From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Muhammad Bilal <meatuni001@gmail.com>
Cc: "Jorge Lopez" <jorge.lopez2@hp.com>,
"Hans de Goede" <hansg@kernel.org>,
"Thomas Weißschuh" <linux@weissschuh.net>,
platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: hp-bioscfg: zero the hex-string decode buffer in hp_convert_hexstr_to_str
Date: Wed, 16 Sep 2026 13:29:49 +0300 (EEST) [thread overview]
Message-ID: <372e11de-9835-ef04-dba8-89faafa00ea6@linux.intel.com> (raw)
In-Reply-To: <20260916004606.165065-1-meatuni001@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2148 bytes --]
On Wed, 16 Sep 2026, Muhammad Bilal wrote:
> hp_convert_hexstr_to_str() allocates its output buffer for the
> worst-case decoded length, then fills in only as many bytes as the
> input actually decodes to before shrinking the allocation down to
> that length with krealloc(). Well-formed input can decode to
> noticeably fewer bytes than the worst case, so the buffer is
> frequently only partially written by the time it is realloc'd and
> returned to the caller.
>
> Use kzalloc() instead of kmalloc() for the initial allocation, so
> any unused capacity starts out zeroed instead of holding leftover
> heap contents, rather than relying on every current and future
> caller and code path to fill the buffer exactly.
>
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
> ---
> Applies on top of "platform/x86: hp-bioscfg: fix slab-out-of-bounds
> write in hp_convert_hexstr_to_str" (the DIV_ROUND_UP sizing fix),
> which Ilpo has applied to review-ilpo-next but is not yet in
> mainline. Sent as its own patch rather than a v3 of that one, since
> the sizing fix itself was applied as-is; this is the separate change
> requested on top of it.
Thanks, applied to review-ilpo-next.
In future, please try to add parenthesis into function names in the
shortlog (on Subject line) as well so I don't need to manually add them
myself.
--
i.
> ---
> drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> index ff28db7..2dab9c0 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> @@ -442,7 +442,7 @@ int hp_convert_hexstr_to_str(const char *input, u32 input_len, char **str, int *
> *len = 0;
> *str = NULL;
>
> - new_str = kmalloc(2 * DIV_ROUND_UP(input_len, 5) + 1, GFP_KERNEL);
> + new_str = kzalloc(2 * DIV_ROUND_UP(input_len, 5) + 1, GFP_KERNEL);
> if (!new_str)
> return -ENOMEM;
>
>
next prev parent reply other threads:[~2026-09-16 10:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 17:46 [PATCH v2] platform/x86: hp-bioscfg: fix slab-out-of-bounds write " Muhammad Bilal
2026-09-15 19:53 ` Ilpo Järvinen
2026-09-16 0:46 ` [PATCH] platform/x86: hp-bioscfg: zero the hex-string decode buffer " Muhammad Bilal
2026-09-16 10:29 ` Ilpo Järvinen [this message]
2026-09-16 10:47 ` Muhammad Bilal
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=372e11de-9835-ef04-dba8-89faafa00ea6@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 \
/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®