Skip to content

Commit 711f8c3

Browse files
committed
Bluetooth: L2CAP: Fix accepting connection request for invalid SPSM
The Bluetooth spec states that the valid range for SPSM is from 0x0001-0x00ff so it is invalid to accept values outside of this range: BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A page 1059: Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges CVE: CVE-2022-42896 CC: [email protected] Reported-by: Tamás Koczka <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]> Reviewed-by: Tedd Ho-Jeong An <[email protected]>
1 parent 5638d9e commit 711f8c3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5813,6 +5813,19 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
58135813
BT_DBG("psm 0x%2.2x scid 0x%4.4x mtu %u mps %u", __le16_to_cpu(psm),
58145814
scid, mtu, mps);
58155815

5816+
/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A
5817+
* page 1059:
5818+
*
5819+
* Valid range: 0x0001-0x00ff
5820+
*
5821+
* Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges
5822+
*/
5823+
if (!psm || __le16_to_cpu(psm) > L2CAP_PSM_LE_DYN_END) {
5824+
result = L2CAP_CR_LE_BAD_PSM;
5825+
chan = NULL;
5826+
goto response;
5827+
}
5828+
58165829
/* Check if we have socket listening on psm */
58175830
pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, &conn->hcon->src,
58185831
&conn->hcon->dst, LE_LINK);
@@ -6001,6 +6014,18 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
60016014

60026015
psm = req->psm;
60036016

6017+
/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 3, Part A
6018+
* page 1059:
6019+
*
6020+
* Valid range: 0x0001-0x00ff
6021+
*
6022+
* Table 4.15: L2CAP_LE_CREDIT_BASED_CONNECTION_REQ SPSM ranges
6023+
*/
6024+
if (!psm || __le16_to_cpu(psm) > L2CAP_PSM_LE_DYN_END) {
6025+
result = L2CAP_CR_LE_BAD_PSM;
6026+
goto response;
6027+
}
6028+
60046029
BT_DBG("psm 0x%2.2x mtu %u mps %u", __le16_to_cpu(psm), mtu, mps);
60056030

60066031
memset(&pdu, 0, sizeof(pdu));

0 commit comments

Comments
 (0)