Linux wireless drivers development
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Falconet3 <Falconet3@proton.me>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>
Subject: RE: [PATCH v4 2/2] wifi: rtw89: fix u32 overflow in board element seek
Date: Fri, 27 Nov 2026 06:47:35 +0000	[thread overview]
Message-ID: <216b618489b640569748f19c964bb199@realtek.com> (raw)
In-Reply-To: <J7Alt6-qlyx7wBUQIFOv5e60k27PLQmMSnJqjcLlsLLZ2US-MP6vo7ny0nCq9WYWBJneWekcQHftkNy86oLzZOCIUJj5RPctR5-py5cvI4U=@proton.me>

Falconet3 <Falconet3@proton.me> wrote:
> rtw89_board_elm_seek() validates the selected entry against the board
> element file with
> 
>         if (unlikely(board_elm->size < ofst + size))
> 
> where ofst and size are u32 values read from the file. The addition
> wraps in u32, so a crafted file with, for example,
> ofst = 0xffffff00 and size = 0x200 passes the check and
> pseudo_fw->data is set to board_elm->data + 0xffffff00 with
> pseudo_fw->size = 0x200. The element walk then dereferences that
> pointer and reads out of bounds.
> 
> Use remainder arithmetic against board_elm->size, which cannot wrap on
> any architecture. The helper is new in v7.4-rc1, so only the current
> cycle is affected.

The same comment as patch 1/2.

> 
> Fixes: af5905e22a43 ("wifi: rtw89: support variants of FW elements")
> Assisted-by: LLM Mistral Vibe
> Signed-off-by: Falconet3 <Falconet3@proton.me>
> ---
> v4: resend as a new thread at the maintainer's request; no code change
>     since v3.
> v3: resend of the series with the correct subjects and version label; no
>     code change since v2.
> v2: new. Found while fixing the element walk bounds check; split out as
>     an independent caller. Compile- and sparse-tested on x86_64; no
>     reproducer available.
> 
>  drivers/net/wireless/realtek/rtw89/fw.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
> --- a/drivers/net/wireless/realtek/rtw89/fw.c
> +++ b/drivers/net/wireless/realtek/rtw89/fw.c
> @@ -1739,7 +1739,8 @@
>         ofst = le32_to_cpu(ent->ofst);
>         size = le32_to_cpu(ent->size);
> 
> -       if (unlikely(board_elm->size < ofst + size))
> +       if (unlikely(ofst > board_elm->size ||
> +                    size > board_elm->size - ofst))

The same comment as patch 1/2.

>                 return -EFAULT;
> 
>         memset(pseudo_fw, 0, sizeof(*pseudo_fw));

pw-bot: cr


      reply	other threads:[~2026-11-27  6:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 18:23 [PATCH v4 2/2] wifi: rtw89: fix u32 overflow in board element seek Falconet3
2026-11-27  6:47 ` Ping-Ke Shih [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=216b618489b640569748f19c964bb199@realtek.com \
    --to=pkshih@realtek.com \
    --cc=Falconet3@proton.me \
    --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