Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH v2] wifi: mwifiex: bound SDIO fw dump count by memory table size
@ 2026-09-23 14:43 Tianchu Chen
  2026-09-25 22:36 ` Brian Norris
  0 siblings, 1 reply; 2+ messages in thread
From: Tianchu Chen @ 2026-09-23 14:43 UTC (permalink / raw)
  To: linux-wireless; +Cc: briannorris, francesco

From: Tianchu Chen <flynnnchen@tencent.com>

mwifiex_sdio_fw_dump() reads the number of memory regions (dump_num)
from a device register and uses it to index the static 15-entry
mem_type_mapping_tbl[] without any bounds check.  A bogus device can
report a dump_num larger than the table; each out-of-table loop
iteration then reads entry->mem_name and entry->done_flag and stores
a vmalloc pointer and a device-controlled size past the end of the
table, into adjacent .data (up to ~5.6KiB when dump_num is 255).

The dump path runs after command timeouts or firmware crashes, so a
bogus device can first force an error to trigger the dump and then
report a bogus dump_num.

Limit dump_num to the table size instead of aborting the dump. This
is not expected to change the behavior on normal devices.

Discovered by Atuin - Automated Vulnerability Discovery Engine.

Fixes: 54881c6b37c8d ("mwifiex: add firmware dump feature for SDIO")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Tianchu Chen <flynnnchen@tencent.com>
---
v2: clamp dump_num to the table size and continue when bogus dump_num
detected.

 drivers/net/wireless/marvell/mwifiex/sdio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c
index f039d6f19183a..c15d6e1dd8f63 100644
--- a/drivers/net/wireless/marvell/mwifiex/sdio.c
+++ b/drivers/net/wireless/marvell/mwifiex/sdio.c
@@ -2795,6 +2795,9 @@ static void mwifiex_sdio_fw_dump(struct mwifiex_adapter *adapter)
 		mwifiex_dbg(adapter, ERROR, "SDIO read memory length err\n");
 		goto done;
 	}
+	/* Limit the dump count to the memory table size */
+	if (dump_num > ARRAY_SIZE(mem_type_mapping_tbl))
+		dump_num = ARRAY_SIZE(mem_type_mapping_tbl);
 
 	/* Read the length of every memory which will dump */
 	for (idx = 0; idx < dump_num; idx++) {
-- 
2.51.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] wifi: mwifiex: bound SDIO fw dump count by memory table size
  2026-09-23 14:43 [PATCH v2] wifi: mwifiex: bound SDIO fw dump count by memory table size Tianchu Chen
@ 2026-09-25 22:36 ` Brian Norris
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2026-09-25 22:36 UTC (permalink / raw)
  To: Tianchu Chen; +Cc: linux-wireless, francesco

On Wed, Sep 23, 2026 at 02:43:51PM +0000, Tianchu Chen wrote:
> From: Tianchu Chen <flynnnchen@tencent.com>
> 
> mwifiex_sdio_fw_dump() reads the number of memory regions (dump_num)
> from a device register and uses it to index the static 15-entry
> mem_type_mapping_tbl[] without any bounds check.  A bogus device can
> report a dump_num larger than the table; each out-of-table loop
> iteration then reads entry->mem_name and entry->done_flag and stores
> a vmalloc pointer and a device-controlled size past the end of the
> table, into adjacent .data (up to ~5.6KiB when dump_num is 255).
> 
> The dump path runs after command timeouts or firmware crashes, so a
> bogus device can first force an error to trigger the dump and then
> report a bogus dump_num.
> 
> Limit dump_num to the table size instead of aborting the dump. This
> is not expected to change the behavior on normal devices.
> 
> Discovered by Atuin - Automated Vulnerability Discovery Engine.
> 
> Fixes: 54881c6b37c8d ("mwifiex: add firmware dump feature for SDIO")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Tianchu Chen <flynnnchen@tencent.com>
> ---
> v2: clamp dump_num to the table size and continue when bogus dump_num
> detected.

Oops, didn't notice v2 when reviewing v1. This is a valid choice too;
probably a better one.

Acked-by: Brian Norris <briannorris@chromium.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-25 22:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23 14:43 [PATCH v2] wifi: mwifiex: bound SDIO fw dump count by memory table size Tianchu Chen
2026-09-25 22:36 ` Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox