summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSungwoo Kim <iam@sung-woo.kim>2023-06-03 08:28:09 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-14 10:57:13 +0200
commit8a2000677d6ee0ef2ec2e6bff8e7572b74a391ef (patch)
tree804a79e64d3d563e0888b123e4468fbb0baf2985 /net
parent5822e209bcfc04fd7d45cc56f5ab0358403ba6c2 (diff)
downloadlinux-stable-8a2000677d6ee0ef2ec2e6bff8e7572b74a391ef.tar.gz
linux-stable-8a2000677d6ee0ef2ec2e6bff8e7572b74a391ef.tar.bz2
linux-stable-8a2000677d6ee0ef2ec2e6bff8e7572b74a391ef.zip
Bluetooth: L2CAP: Add missing checks for invalid DCID
[ Upstream commit 75767213f3d9b97f63694d02260b6a49a2271876 ] 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: 40624183c202 ("Bluetooth: L2CAP: Add missing checks for invalid LE DCID") Signed-off-by: Sungwoo Kim <iam@sung-woo.kim> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/l2cap_core.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d91ddcd54e27..fcc471f92189 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4007,6 +4007,10 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
result = __le16_to_cpu(rsp->result);
status = __le16_to_cpu(rsp->status);
+ if (result == L2CAP_CR_SUCCESS && (dcid < L2CAP_CID_DYN_START ||
+ dcid > L2CAP_CID_DYN_END))
+ return -EPROTO;
+
BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x",
dcid, scid, result, status);
@@ -4038,6 +4042,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,
switch (result) {
case L2CAP_CR_SUCCESS:
+ if (__l2cap_get_chan_by_dcid(conn, dcid)) {
+ err = -EBADSLT;
+ break;
+ }
+
l2cap_state_change(chan, BT_CONFIG);
chan->ident = 0;
chan->dcid = dcid;