Skip to content

Commit 7576721

Browse files
swkim101Vudentz
authored andcommitted
Bluetooth: L2CAP: Add missing checks for invalid DCID
When receiving a connect response we should make sure that the DCID is within the valid range and that we don't already have another channel allocated for the same DCID. Missing checks may violate the specification (BLUETOOTH CORE SPECIFICATION Version 5.4 | Vol 3, Part A, Page 1046). Fixes: 4062418 ("Bluetooth: L2CAP: Add missing checks for invalid LE DCID") Signed-off-by: Sungwoo Kim <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 71e9588 commit 7576721

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4306,6 +4306,10 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
43064306
result = __le16_to_cpu(rsp->result);
43074307
status = __le16_to_cpu(rsp->status);
43084308

4309+
if (result == L2CAP_CR_SUCCESS && (dcid < L2CAP_CID_DYN_START ||
4310+
dcid > L2CAP_CID_DYN_END))
4311+
return -EPROTO;
4312+
43094313
BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x",
43104314
dcid, scid, result, status);
43114315

@@ -4337,6 +4341,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
43374341

43384342
switch (result) {
43394343
case L2CAP_CR_SUCCESS:
4344+
if (__l2cap_get_chan_by_dcid(conn, dcid)) {
4345+
err = -EBADSLT;
4346+
break;
4347+
}
4348+
43404349
l2cap_state_change(chan, BT_CONFIG);
43414350
chan->ident = 0;
43424351
chan->dcid = dcid;

0 commit comments

Comments
 (0)