Skip to content

Commit bb77543

Browse files
committed
Bluetooth: Restrict valid packet types via HCI_CHANNEL_RAW
When using the HCI_CHANNEL_RAW, restrict the packet types to valid ones from the Bluetooth specification. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1 parent 8cd4f58 commit bb77543

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

net/bluetooth/hci_sock.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
170170
continue;
171171

172172
if (hci_pi(sk)->channel == HCI_CHANNEL_RAW) {
173+
if (bt_cb(skb)->pkt_type != HCI_COMMAND_PKT &&
174+
bt_cb(skb)->pkt_type != HCI_EVENT_PKT &&
175+
bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT &&
176+
bt_cb(skb)->pkt_type != HCI_SCODATA_PKT)
177+
continue;
173178
if (is_filtered_packet(sk, skb))
174179
continue;
175180
} else if (hci_pi(sk)->channel == HCI_CHANNEL_USER) {
@@ -1247,6 +1252,12 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
12471252
goto drop;
12481253
}
12491254

1255+
if (bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT &&
1256+
bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) {
1257+
err = -EINVAL;
1258+
goto drop;
1259+
}
1260+
12501261
skb_queue_tail(&hdev->raw_q, skb);
12511262
queue_work(hdev->workqueue, &hdev->tx_work);
12521263
}

0 commit comments

Comments
 (0)