* Re: [PATCH v3 2/2] wifi: rtw89: fix u32 overflow in board element offset check
@ 2026-11-22 11:07 Falconet3
2026-11-22 11:21 ` Falconet3
0 siblings, 1 reply; 4+ messages in thread
From: Falconet3 @ 2026-11-22 11:07 UTC (permalink / raw)
To: pkshih; +Cc: linux-wireless, linux-kernel
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.
Fixes: af5905e22a43 ("wifi: rtw89: support variants of FW elements")
Assisted-by: LLM Mistral Vibe
Signed-off-by: Falconet3 <Falconet3@proton.me>
---
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
index 0000000..0000000 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -1734,12 +1734,13 @@ static int rtw89_board_elm_seek(const struct firmware *board_elm,
if (num <= board_id)
return -ENOENT;
ent = &hdr->ents[board_id];
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))
return -EFAULT;
memset(pseudo_fw, 0, sizeof(*pseudo_fw));
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 2/2] wifi: rtw89: fix u32 overflow in board element offset check
2026-11-22 11:07 [PATCH v3 2/2] wifi: rtw89: fix u32 overflow in board element offset check Falconet3
@ 2026-11-22 11:21 ` Falconet3
2026-11-23 0:50 ` Ping-Ke Shih
0 siblings, 1 reply; 4+ messages in thread
From: Falconet3 @ 2026-11-22 11:21 UTC (permalink / raw)
To: pkshih; +Cc: linux-wireless, linux-kernel
Note: 2/2 was posted as a standalone message ("[PATCH v3 2/2] wifi: rtw89:
fix u32 overflow in board element offset check") because my webmail client
does not preserve the In-Reply-To header when the subject is edited. Both
patches are independent and apply on top of v7.4-rc3.
Sorry for the confusion,
Falconet3
Enviado com um e-mail seguro do Proton Mail.
Em domingo, 22 de novembro de 2026 às 11:07, Falconet3 <Falconet3@proton.me> escreveu:
> 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.
>
> Fixes: af5905e22a43 ("wifi: rtw89: support variants of FW elements")
> Assisted-by: LLM Mistral Vibe
> Signed-off-by: Falconet3 <Falconet3@proton.me>
> ---
> 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
> index 0000000..0000000 100644
> --- a/drivers/net/wireless/realtek/rtw89/fw.c
> +++ b/drivers/net/wireless/realtek/rtw89/fw.c
> @@ -1734,12 +1734,13 @@ static int rtw89_board_elm_seek(const struct firmware *board_elm,
> if (num <= board_id)
> return -ENOENT;
>
> ent = &hdr->ents[board_id];
>
> 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))
> return -EFAULT;
>
> memset(pseudo_fw, 0, sizeof(*pseudo_fw));
> --
> 2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 2/2] wifi: rtw89: fix u32 overflow in board element offset check
@ 2026-11-22 11:19 Falconet3
0 siblings, 0 replies; 4+ messages in thread
From: Falconet3 @ 2026-11-22 11:19 UTC (permalink / raw)
To: pkshih; +Cc: linux-wireless, linux-kernel
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.
Fixes: af5905e22a43 ("wifi: rtw89: support variants of FW elements")
Assisted-by: LLM Mistral Vibe
Signed-off-by: Falconet3 <Falconet3@proton.me>
---
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
index 0000000..0000000 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -1734,12 +1734,13 @@ static int rtw89_board_elm_seek(const struct firmware *board_elm,
if (num <= board_id)
return -ENOENT;
ent = &hdr->ents[board_id];
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))
return -EFAULT;
memset(pseudo_fw, 0, sizeof(*pseudo_fw));
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 0:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22 11:07 [PATCH v3 2/2] wifi: rtw89: fix u32 overflow in board element offset check Falconet3
2026-11-22 11:21 ` Falconet3
2026-11-23 0:50 ` Ping-Ke Shih
2026-11-22 11:19 Falconet3
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®