Skip to content
/ linux Public

Commit 8d0d94f

Browse files
Vudentzgregkh
authored andcommitted
Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ
commit 5b3e205 upstream. Currently the code attempts to accept requests regardless of the command identifier which may cause multiple requests to be marked as pending (FLAG_DEFER_SETUP) which can cause more than L2CAP_ECRED_MAX_CID(5) to be allocated in l2cap_ecred_rsp_defer causing an overflow. The spec is quite clear that the same identifier shall not be used on subsequent requests: 'Within each signaling channel a different Identifier shall be used for each successive request or indication.' https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-62/out/en/host/logical-link-control-and-adaptation-protocol-specification.html#UUID-32a25a06-4aa4-c6c7-77c5-dcfe3682355d So this attempts to check if there are any channels pending with the same identifier and rejects if any are found. Fixes: 15f02b9 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode") Reported-by: Yiming Qian <yimingqian591@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1e9e264 commit 8d0d94f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5045,7 +5045,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
50455045
u16 mtu, mps;
50465046
__le16 psm;
50475047
u8 result, rsp_len = 0;
5048-
int i, num_scid;
5048+
int i, num_scid = 0;
50495049
bool defer = false;
50505050

50515051
if (!enable_ecred)
@@ -5058,6 +5058,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
50585058
goto response;
50595059
}
50605060

5061+
/* Check if there are no pending channels with the same ident */
5062+
__l2cap_chan_list_id(conn, cmd->ident, l2cap_ecred_list_defer,
5063+
&num_scid);
5064+
if (num_scid) {
5065+
result = L2CAP_CR_LE_INVALID_PARAMS;
5066+
goto response;
5067+
}
5068+
50615069
cmd_len -= sizeof(*req);
50625070
num_scid = cmd_len / sizeof(u16);
50635071

0 commit comments

Comments
 (0)