Skip to contentSkip to conversation

Bluetooth: hci_bcm4377: fix OOB read from firmware event length in completion ring

PATCH Superseded Tristan Madani 2 participants 2 messages Apr 15

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Bluetooth: hci_bcm4377: fix OOB read from firmware event length in completion ring

From: Tristan Madani <[email protected]>

The firmware-controlled entry->len is used as the memcpy size for inline payload data without bounds checking when the PAYLOAD_MAPPED flag is not set. This causes out-of-bounds reads from the completion ring DMA memory for the HCI_D2H and SCO_D2H transfer rings.

Add a length validation against the completion ring payload_size.

Fixes 8a06127602de ("Bluetooth: hci_bcm4377: Add new driver for BCM4377 PCIe boards")

---
Note: v2 resubmission -- original sent via Gmail had HTML rendering issues. This version uses git send-email for plain-text formatting.

drivers/bluetooth/hci_bcm4377.c | 8 ++++++++

 1 file changed, 8 insertions(+)
drivers/bluetooth/hci_bcm4377.c +8 -0
index XXXXXXX..XXXXXXX 100644
@@ -754,6 +754,14 @@ static void bcm4377_handle_completion(struct bcm4377_data *bcm4377,
 	data_len = le32_to_cpu(entry->len);
 	msg_id = le16_to_cpu(entry->msg_id);
 	transfer_ring = le16_to_cpu(entry->ring_id);
+
+	if (data_len > ring->payload_size) {
+		dev_warn(&bcm4377->pdev->dev,
+			 "event data len %zu exceeds payload size %zu for completion ring %d\n",
+			 data_len, ring->payload_size, ring->ring_id);
+		return;
+	}
+
 	if ((ring->transfer_rings & BIT(transfer_ring)) == 0) {
 		dev_warn(
 
#1 lore raw

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: patch failed: drivers/bluetooth/hci_bcm4377.c:754
error: drivers/bluetooth/hci_bcm4377.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch

Please resolve the issue and submit the patches again.

---
Regards,
Linux Bluetooth