Skip to content

Commit c65bd94

Browse files
V4belVudentz
authored andcommitted
Bluetooth: L2CAP: Validate PDU length before reading SDU length in l2cap_ecred_data_rcv()
l2cap_ecred_data_rcv() reads the SDU length field from skb->data using get_unaligned_le16() without first verifying that skb contains at least L2CAP_SDULEN_SIZE (2) bytes. When skb->len is less than 2, this reads past the valid data in the skb. The ERTM reassembly path correctly calls pskb_may_pull() before reading the SDU length (l2cap_reassemble_sdu, L2CAP_SAR_START case). Apply the same validation to the Enhanced Credit Based Flow Control data path. Fixes: aac23bf ("Bluetooth: Implement LE L2CAP reassembly") Signed-off-by: Hyunwoo Kim <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 9d87cb2 commit c65bd94

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

net/bluetooth/l2cap_core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6690,6 +6690,11 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
66906690
if (!chan->sdu) {
66916691
u16 sdu_len;
66926692

6693+
if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE)) {
6694+
err = -EINVAL;
6695+
goto failed;
6696+
}
6697+
66936698
sdu_len = get_unaligned_le16(skb->data);
66946699
skb_pull(skb, L2CAP_SDULEN_SIZE);
66956700

0 commit comments

Comments
 (0)