* [PATCH] Bluetooth: btmrvl_sdio: Bound fw dump count by memory table size
@ 2026-11-25 12:13 Maoyi Xie
2026-11-25 21:11 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Maoyi Xie @ 2026-11-25 12:13 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz; +Cc: linux-bluetooth
btmrvl_sdio_coredump() runs when root writes the coredump attribute. It
reads the number of memory regions, dump_num, from a card register. Two
loops then walk mem_type_mapping_tbl[] up to dump_num, but the table has
15 entries.
If the card reports more than 15, the first loop can store a vzalloc()
pointer and a size past the table. The second loop copies from the
pointer it finds there, then frees it.
Limit dump_num to the size of the table, as commit dbca9dfd3bfc
("wifi: mwifiex: bound SDIO fw dump count by memory table size") did in
mwifiex.
Found with a CodeQL-based static analysis tool that we are developing.
Reproduced in a userspace harness under AddressSanitizer. Not tested on
hardware.
Fixes: dc759613b024 ("Bluetooth: btmrvl add firmware dump support")
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.
drivers/bluetooth/btmrvl_sdio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 4fd241693a10..cbf63e737ff0 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -1378,6 +1378,10 @@ static void btmrvl_sdio_coredump(struct device *dev)
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++) {
struct memory_type_mapping *entry = &mem_type_mapping_tbl[idx];
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-25 21:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 12:13 [PATCH] Bluetooth: btmrvl_sdio: Bound fw dump count by memory table size Maoyi Xie
2026-11-25 21:11 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox