Skip to contentSkip to conversation

Bluetooth: hci_event: Use skb_pull_data when processing inquiry results

PATCH In review Luiz Augusto von Dentz 2 participants 2 messages Dec 13, 2021 – Dec 22, 2021

Subsystems (2)
lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Bluetooth: hci_event: Use skb_pull_data when processing inquiry results

From: Luiz Augusto von Dentz <[email protected]>

This makes each result entry to be checked using skb_pull_data instead of acessing them by index.

---
 net/bluetooth/hci_event.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
net/bluetooth/hci_event.c +18 -2
index 9151d70b36b0..f1082b7c0218 100644
@@ -4530,7 +4530,15 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, void *edata,
 		for (i = 0; i < ev->res2->num; i++) {
 			u32 flags;
 
-			info = &ev->res2->info[i];
+			info = hci_ev_skb_pull(hdev, skb,
+					       HCI_EV_INQUIRY_RESULT_WITH_RSSI,
+					       sizeof(*info));
+			if (!info) {
+				bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x",
+					   HCI_EV_INQUIRY_RESULT_WITH_RSSI);
+				return;
+			}
+
 			bacpy(&data.bdaddr, &info->bdaddr);
 			data.pscan_rep_mode	= info->pscan_rep_mode;
 			data.pscan_period_mode	= info->pscan_period_mode;
@@ -4552,7 +4560,15 @@ static void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, void *edata,
 		for (i = 0; i < ev->res1->num; i++) {
 			u32 flags;
 
-			info = &ev->res1->info[i];
+			info = hci_ev_skb_pull(hdev, skb,
+					       HCI_EV_INQUIRY_RESULT_WITH_RSSI,
+					       sizeof(*info));
+			if (!info) {
+				bt_dev_err(hdev, "Malformed HCI Event: 0x%2.2x",
+					   HCI_EV_INQUIRY_RESULT_WITH_RSSI);
+				return;
+			}
+
 			bacpy(&data.bdaddr, &info->bdaddr);
 			data.pscan_rep_mode	= info->pscan_rep_mode;
 			data.pscan_period_mode	= info->pscan_period_mode;
Signature · 1 line
2.33.1
maintainer
#1 lore raw

Hi Luiz,

Quoted 7 lines

This makes each result entry to be checked using skb_pull_data instead of acessing them by index.

---
net/bluetooth/hci_event.c | 20 ++++++++++++++++++--

1 file changed, 18 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel