public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: btintel_pcie: validate RX packet length against buffer size
@ 2026-04-02  8:28 Junrui Luo
  2026-04-02  8:55 ` [v2] " bluez.test.bot
  2026-04-09 20:19 ` bluez.test.bot
  0 siblings, 2 replies; 3+ messages in thread
From: Junrui Luo @ 2026-04-02  8:28 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz, Kiran K,
	Tedd Ho-Jeong An
  Cc: Luiz Augusto von Dentz, linux-bluetooth, linux-kernel,
	Yuhao Jiang, stable, Paul Menzel, Junrui Luo

btintel_pcie_submit_rx_work() reads packet_len from an rfh_hdr in
DMA-coherent memory and uses it as the length for skb_put_data() without
upper bound validation. Since packet_len is a 16-bit field (0-65535) but
each RX DMA buffer is only BTINTEL_PCIE_BUFFER_SIZE (4096) bytes, a
malicious or malfunctioning firmware could set a large packet_len,
causing an out-of-bounds read beyond the buffer into adjacent kernel
heap memory.

Add a check that packet_len does not exceed the available payload space
alongside the existing zero-length check.

Fixes: c2b636b3f788 ("Bluetooth: btintel_pcie: Add support for PCIe transport")
Reported-by: Yuhao Jiang <danisjiang@gmail.com>
Cc: stable@vger.kernel.org
Cc: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
---
Changes in v2:
- Add bt_dev_warn() to log error suggested by Paul Menzel
- Link to v1: https://lore.kernel.org/all/SYBPR01MB7881DD95CE054BC53AED4A21AF41A@SYBPR01MB7881.ausprd01.prod.outlook.com/
---
 drivers/bluetooth/btintel_pcie.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btintel_pcie.c b/drivers/bluetooth/btintel_pcie.c
index 37b744e35bc4..e60487e73749 100644
--- a/drivers/bluetooth/btintel_pcie.c
+++ b/drivers/bluetooth/btintel_pcie.c
@@ -1360,7 +1360,9 @@ static int btintel_pcie_submit_rx_work(struct btintel_pcie_data *data, u8 status
 	rfh_hdr = buf;
 
 	len = rfh_hdr->packet_len;
-	if (len <= 0) {
+	if (len <= 0 ||
+	    len > BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr)) {
+		bt_dev_warn(data->hdev, "Invalid RX packet length: %d", len);
 		ret = -EINVAL;
 		goto resubmit;
 	}

---
base-commit: 7aaa8047eafd0bd628065b15757d9b48c5f9c07d
change-id: 20260402-fixes-979e727e99f1

Best regards,
-- 
Junrui Luo <moonafterrain@outlook.com>


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

end of thread, other threads:[~2026-04-09 20:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02  8:28 [PATCH v2] Bluetooth: btintel_pcie: validate RX packet length against buffer size Junrui Luo
2026-04-02  8:55 ` [v2] " bluez.test.bot
2026-04-09 20:19 ` 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