X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: yahia <yahia.a.abdrabou@gmail.com>
Cc: platform-driver-x86@vger.kernel.org, sashiko-bot@kernel.org
Subject: Re: [PATCH 2/3] hp-wmi: fix potential integer underflow
Date: Mon, 13 Jul 2026 14:23:46 +0300 (EEST)	[thread overview]
Message-ID: <2c2be85b-62e0-8431-9cc5-1cdc48c1c149@linux.intel.com> (raw)
In-Reply-To: <20260712191130.41183-3-yahia.a.abdrabou@gmail.com>

On Sun, 12 Jul 2026, yahia wrote:

> From: yahia ahmed <yahia.a.abdrabou@gmail.com>
> 
> hp_wmi_query_perform() currently calculates the output size of the
> returned buffer by subtracting the size of bios_return from the length
> sent, However if a malicious bios or a new bios not yet tracked or
> handled sends a length smaller than the size of bios_return, the
> calculation will underflow, then the result will be casted to a signed
> integer, as such the min() function will fail to set the size properly
> leading to a huge number to be passed to memcpy.
> 
> Fix this by adding a check to ensure if the length returned by the bios
> is larger than bios_return.
> 
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/patchset/20260706143855.35002-1-yahia.a.abdrabou%40gmail.com
> Fixes: d35c9a029a73 ("platform/x86: hp-wmi: Don't log a warning on HPWMI_RET_UNKNOWN_COMMAND errors")
> Signed-off-by: yahia ahmed <yahia.a.abdrabou@gmail.com>
> ---
>  drivers/platform/x86/hp/hp-wmi.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index c924fbb5503f..3235ade2fa98 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -634,6 +634,10 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
>  	if (!outsize)
>  		return ret;
>  
> +	if (obj->buffer.length < sizeof(*bios_return)) {

This driver is using a deprecated WMI API.

The new WMI API may be able to do size checks for you so you don't need 
to add them to the driver side.

> +		pr_warn("Bios returned invalid data");
> +		return -EINVAL;
> +	}
>  	actual_outsize = min(outsize, (int)(obj->buffer.length - sizeof(*bios_return)));
>  	memcpy(buffer, obj->buffer.pointer + sizeof(*bios_return), actual_outsize);
>  	memset(buffer + actual_outsize, 0, outsize - actual_outsize);
> 

-- 
 i.


  reply	other threads:[~2026-07-13 11:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 19:11 [PATCH 0/3]: hp-wmi: fix various issues with yahia
2026-07-12 19:11 ` [PATCH 1/3] hp-wmi: refactor to use __free yahia
2026-07-13 11:21   ` Ilpo Järvinen
2026-07-12 19:11 ` [PATCH 2/3] hp-wmi: fix potential integer underflow yahia
2026-07-13 11:23   ` Ilpo Järvinen [this message]
2026-07-13 12:24     ` yahia
2026-07-12 19:11 ` [PATCH 3/3] hp-wmi: move from kmalloc to kzalloc yahia
2026-07-13 11:30   ` 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=2c2be85b-62e0-8431-9cc5-1cdc48c1c149@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=yahia.a.abdrabou@gmail.com \
    /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