Commit 318ce727 authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

[Bluetooth] Detect and log error condition when first L2CAP fragment is too long.

parent cb75e1ff
...@@ -1940,21 +1940,27 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl ...@@ -1940,21 +1940,27 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
} }
if (skb->len < 2) { if (skb->len < 2) {
BT_ERR("Frame is too small (len %d)", skb->len); BT_ERR("Frame is too short (len %d)", skb->len);
goto drop; goto drop;
} }
hdr = (struct l2cap_hdr *) skb->data; hdr = (struct l2cap_hdr *) skb->data;
len = __le16_to_cpu(hdr->len) + L2CAP_HDR_SIZE; len = __le16_to_cpu(hdr->len) + L2CAP_HDR_SIZE;
BT_DBG("Start: total len %d, frag len %d", len, skb->len);
if (len == skb->len) { if (len == skb->len) {
/* Complete frame received */ /* Complete frame received */
l2cap_recv_frame(conn, skb); l2cap_recv_frame(conn, skb);
return 0; return 0;
} }
BT_DBG("Start: total len %d, frag len %d", len, skb->len);
if (skb->len > len) {
BT_ERR("Frame is too long (len %d, expected len %d)",
skb->len, len);
goto drop;
}
/* Allocate skb for the complete frame (with header) */ /* Allocate skb for the complete frame (with header) */
if (!(conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC))) if (!(conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC)))
goto drop; goto drop;
...@@ -1970,7 +1976,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl ...@@ -1970,7 +1976,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
} }
if (skb->len > conn->rx_len) { if (skb->len > conn->rx_len) {
BT_ERR("Fragment is too large (len %d, expect %d)", BT_ERR("Fragment is too long (len %d, expected %d)",
skb->len, conn->rx_len); skb->len, conn->rx_len);
kfree_skb(conn->rx_skb); kfree_skb(conn->rx_skb);
conn->rx_skb = NULL; conn->rx_skb = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment