Linux wireless drivers development
 help / color / mirror / Atom feed
From: "Jérôme Pouiller" <jerome.pouiller@silabs.com>
To: linux-wireless@vger.kernel.org, Aamir Ahmed <elb12345@hotmail.co.uk>
Cc: gregkh@linuxfoundation.org, Aamir Ahmed <elb12345@hotmail.co.uk>
Subject: Re: [PATCH] wifi: wfx: validate MIB read length before copying to caller
Date: Mon, 07 Sep 2026 17:36:20 +0200	[thread overview]
Message-ID: <4736844.8F6SAcFxjW@nb0018864> (raw)
In-Reply-To: <AS8P251MB00014841C19595C74C545C80C8B22@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM>

On Monday 7 September 2026 05:17:57 Central European Summer Time Aamir Ahmed wrote:
> wfx_hif_read_mib() copies reply->length bytes from the firmware
> response into the caller-provided buffer without checking that
> reply->length does not exceed val_len. A firmware response with
> a length field larger than expected causes a heap buffer overflow
> when writing to the caller buffer.
> 
> Replace the dead -ENOMEM check with an active validation that
> reply->length fits within val_len before the memcpy.
> 
> Fixes: 9bca45f3d692 ("staging: wfx: allow to send 802.11 frames")
> Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>

Note you should add LKML in Cc: of all your patches (see [1]).

This kind of bug are typically spotted by AI agents. If you have used
a such tool to discover/fix/review the issue, you are supposed to
comply with [2].

[1]: scripts/get_maintainer.pl
[2]: Documentation/process/generated-content.rst  

> ---
>  drivers/net/wireless/silabs/wfx/hif_tx.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/silabs/wfx/hif_tx.c b/drivers/net/wireless/silabs/wfx/hif_tx.c
> index 9f403d275cb1..a6bc1c522e3c 100644
> --- a/drivers/net/wireless/silabs/wfx/hif_tx.c
> +++ b/drivers/net/wireless/silabs/wfx/hif_tx.c
> @@ -207,9 +207,11 @@ int wfx_hif_read_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, void *val, si
>                 dev_warn(wdev->dev, "%s: confirmation mismatch request\n", __func__);
>                 ret = -EIO;
>         }
> -       if (ret == -ENOMEM)
> +       if (!ret && le16_to_cpu(reply->length) > val_len) {
>                 dev_err(wdev->dev, "buffer is too small to receive %s (%zu < %d)\n",
>                         wfx_get_mib_name(mib_id), val_len, le16_to_cpu(reply->length));
> +               ret = -EINVAL;

I believe -EIO would be more consistent. Otherwise, LGTM.


-- 
Jérôme Pouiller



  reply	other threads:[~2026-09-07 15:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07  3:17 [PATCH] wifi: wfx: validate MIB read length before copying to caller Aamir Ahmed
2026-09-07 15:36 ` Jérôme Pouiller [this message]
2026-09-08  1:06   ` Aamir Ahmed

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=4736844.8F6SAcFxjW@nb0018864 \
    --to=jerome.pouiller@silabs.com \
    --cc=elb12345@hotmail.co.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-wireless@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