mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Tristan Madani <tristmd@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Anssi Hannula <anssi.hannula@iki.fi>,
	 Matthew Garrett <mjg59@srcf.ucam.org>,
	platform-driver-x86@vger.kernel.org,
	 LKML <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org,
	 Tristan Madani <tristan@talencesecurity.com>
Subject: Re: [PATCH] platform/x86: hp-wmi: validate WMI return buffer length
Date: Mon, 9 Nov 2026 18:29:50 +0200 (EET)	[thread overview]
Message-ID: <c8985e22-3f00-b32b-3de2-65e486b367db@linux.intel.com> (raw)
In-Reply-To: <20261024205519.4029617-1-tristmd@gmail.com>

On Sat, 24 Oct 2026, Tristan Madani wrote:

> From: Tristan Madani <tristan@talencesecurity.com>
> 
> hp_wmi_perform_query() casts the WMI return buffer to struct
> bios_return without first checking that the buffer is large enough.
> If firmware returns a buffer shorter than sizeof(struct bios_return),
> the subsequent subtraction on buffer.length underflows, causing
> memcpy to copy a near-maximal number of bytes and crash the kernel.

Where's the crash output then? Please quote it in the changelog for the 
relevant parts.

> Add a buffer length check before accessing the return data, matching
> the validation already present in the sibling hp-bioscfg driver.

More important though, hp-wmi should migrate to using the modern WMI API 
which would likely allow using WMI core to validate the output sizes.

Somebody tried the WMI conversion earlier but to me that patch looked 
incorrect (or more like clearly missing pieces) and I had bad experiences 
with the particular submitter when it comes to converging to something 
sensible based on given feedback so I've low prioritized that patch.

> Fixes: c3021ea1beee ("hp-wmi: allow setting input and output buffer sizes separately")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tristan Madani <tristan@talencesecurity.com>
> ---
>  drivers/platform/x86/hp/hp-wmi.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c
> index 615b4cf6fc451..81c0acc874f8e 100644
> --- a/drivers/platform/x86/hp/hp-wmi.c
> +++ b/drivers/platform/x86/hp/hp-wmi.c
> @@ -697,6 +697,13 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
>  		goto out_free;
>  	}
>  
> +	if (obj->buffer.length < sizeof(*bios_return)) {
> +		pr_warn("query 0x%x returned undersized buffer (%u < %zu)\n",
> +			query, obj->buffer.length, sizeof(*bios_return));
> +		ret = -EINVAL;
> +		goto out_free;
> +	}
> +
>  	bios_return = (struct bios_return *)obj->buffer.pointer;
>  	ret = bios_return->return_code;
>  
> 

-- 
 i.


      reply	other threads:[~2026-11-09 16:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24 20:55 Tristan Madani
2026-11-09 16:29 ` Ilpo Järvinen [this message]

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=c8985e22-3f00-b32b-3de2-65e486b367db@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=anssi.hannula@iki.fi \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tristan@talencesecurity.com \
    --cc=tristmd@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

all inboxes | Powered by JetHome®