From: Ali Ahmet Memis <ali@iusegentoo.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, neeraj.sanjaykale@nxp.com,
amitkumar.karwar@nxp.com, marcel@holtmann.org, alex.zhou@nxp.com,
song.xue_1@nxp.com, linux-kernel@vger.kernel.org
Subject: [PATCH v3] Bluetooth: btnxpuart: Validate the FW dump header length
Date: Fri, 14 Aug 2026 18:28:48 +0000 [thread overview]
Message-ID: <20260814182849.940976-1-ali@iusegentoo.com> (raw)
In-Reply-To: <CABBYNZKVQ0CxsviF92iP1Hj2rBiH_hmmEHirp8D=b-DvuaTNeA@mail.gmail.com>
nxp_process_fw_dump() pulls the ACL header off the frame and then reads
seq_num and buf_len from a struct nxp_fw_dump_hdr placed at skb->data,
without checking that the ACL payload is long enough to contain it.
h4_recv_buf() collects HCI_ACL_HDR_SIZE bytes of header followed by the
number of payload bytes named in that header, so skb->len is 4 + dlen
with dlen supplied by the controller and possibly smaller than the 8
byte dump header, or zero. A short frame with connection handle 0xfff
therefore reads both fields from beyond the received data.
Beyond the read itself, buf_len is what terminates a dump: a value of
zero makes the driver call hci_devcd_complete() and reset the
controller, so a truncated frame can end a dump early.
Use skb_pull_data() to validate and pull the FW dump header before
accessing its fields. Warn and reject the chunk if the header is
truncated.
Fixes: 998e447f443f ("Bluetooth: btnxpuart: Add support for HCI coredump feature")
Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
---
v3: Use skb_pull_data() to validate and pull the FW dump header, as
suggested by Luiz.
v2: Warn on the early exit path instead of dropping the frame silently,
as suggested by Neeraj. Dropped the trailing newline from the
suggested message, since bt_dev_warn() already appends one.
v1: https://lore.kernel.org/all/20260814081221.913676-1-ali@iusegentoo.com/
drivers/bluetooth/btnxpuart.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 6a1cffe08d5f..e6c15bc6a30b 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1368,12 +1368,21 @@ static int nxp_process_fw_dump(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_acl_hdr *acl_hdr = (struct hci_acl_hdr *)skb_pull_data(skb,
sizeof(*acl_hdr));
- struct nxp_fw_dump_hdr *fw_dump_hdr = (struct nxp_fw_dump_hdr *)skb->data;
+ struct nxp_fw_dump_hdr *fw_dump_hdr;
struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
- __u16 seq_num = __le16_to_cpu(fw_dump_hdr->seq_num);
- __u16 buf_len = __le16_to_cpu(fw_dump_hdr->buf_len);
+ __u16 seq_num;
+ __u16 buf_len;
int err;
+ fw_dump_hdr = skb_pull_data(skb, sizeof(*fw_dump_hdr));
+ if (!fw_dump_hdr) {
+ bt_dev_warn(hdev, "FW dump: invalid or corrupt fw dump chunk");
+ goto free_skb;
+ }
+
+ seq_num = __le16_to_cpu(fw_dump_hdr->seq_num);
+ buf_len = __le16_to_cpu(fw_dump_hdr->buf_len);
+
if (seq_num == 0x0001) {
if (test_and_set_bit(BTNXPUART_FW_DUMP_IN_PROGRESS, &nxpdev->tx_state)) {
bt_dev_err(hdev, "FW dump already in progress");
--
2.55.0
next prev parent reply other threads:[~2026-08-14 18:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 8:12 [PATCH] Bluetooth: btnxpuart: Validate the FW dump header length Ali Ahmet Memis
2026-08-14 8:33 ` Neeraj Kale
2026-08-14 8:41 ` [PATCH v2] " Ali Ahmet Memis
2026-08-14 8:58 ` Neeraj Kale
2026-08-14 9:41 ` [v2] " bluez.test.bot
2026-08-14 14:08 ` [PATCH v2] " Luiz Augusto von Dentz
2026-08-14 18:28 ` Ali Ahmet Memis [this message]
2026-08-14 19:23 ` [v3] " bluez.test.bot
2026-08-17 19:46 ` [PATCH v3] " patchwork-bot+bluetooth
2026-08-17 6:23 ` [PATCH v2] " Neeraj Kale
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=20260814182849.940976-1-ali@iusegentoo.com \
--to=ali@iusegentoo.com \
--cc=alex.zhou@nxp.com \
--cc=amitkumar.karwar@nxp.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=neeraj.sanjaykale@nxp.com \
--cc=song.xue_1@nxp.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.