Linux bluetooth development
 help / color / mirror / Atom feed
From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: [PATCH] Bluetooth: btmrvl_sdio: Bound fw dump count by memory table size
Date: Wed, 25 Nov 2026 20:13:04 +0800	[thread overview]
Message-ID: <20261125121304.1602985-1-maoyixie.tju@gmail.com> (raw)

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


             reply	other threads:[~2026-11-25 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 12:13 Maoyi Xie [this message]
2026-11-25 21:11 ` Bluetooth: btmrvl_sdio: Bound fw dump count by memory table size bluez.test.bot

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=20261125121304.1602985-1-maoyixie.tju@gmail.com \
    --to=maoyixie.tju@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.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