Skip to contentSkip to conversation

Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ

PATCH Superseded Luiz Augusto von Dentz 2 participants 2 messages Mar 6

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/1 Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ

From: Luiz Augusto von Dentz <[email protected]>

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 15f02b910562 ("Bluetooth: L2CAP: Add initial code for Enhanced Credit Based Mode")
---
 net/bluetooth/l2cap_core.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/bluetooth/l2cap_core.c +7 -0
index 6606d7f12534..d6b5829250bc 100644
@@ -5068,6 +5068,13 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,
 		goto response;
 	}
 
+	/* Check if there are no pending channels with the same ident */
+	__l2cap_chan_list_id(conn, cmd->ident, l2cap_ecred_list_defer, &result);
+	if (result) {
+		result = L2CAP_CR_LE_INVALID_PARAMS;
+		goto response;
+	}
+
 	cmd_len -= sizeof(*req);
 	num_scid = cmd_len / sizeof(u16);
 
Signature · 1 line
2.53.0
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1062835

---Test result---

Test Summary:

CheckPatch                    PENDING   0.43 seconds
GitLint                       PENDING   0.41 seconds
SubjectPrefix                 PASS      0.08 seconds
BuildKernel                   PASS      25.94 seconds
CheckAllWarning               PASS      29.39 seconds
CheckSparse                   WARNING   32.74 seconds
BuildKernel32                 PASS      26.58 seconds
TestRunnerSetup               PASS      569.75 seconds
TestRunner_l2cap-tester       FAIL      29.55 seconds
TestRunner_iso-tester         PASS      80.96 seconds
TestRunner_bnep-tester        PASS      6.38 seconds
TestRunner_mgmt-tester        FAIL      128.88 seconds
TestRunner_rfcomm-tester      PASS      9.50 seconds
TestRunner_sco-tester         FAIL      14.86 seconds
TestRunner_ioctl-tester       PASS      10.58 seconds
TestRunner_mesh-tester        FAIL      12.54 seconds
TestRunner_smp-tester         PASS      9.31 seconds
TestRunner_userchan-tester    PASS      6.83 seconds
IncrementalBuild              PENDING   0.88 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/l2cap_core.c:7799:1: error: bad constant expressionnet/bluetooth/l2cap_core.c:7800:1: error: bad constant expressionnet/bluetooth/l2cap_core.c:7802:1: error: bad constant expressionnet/bluetooth/l2cap_core.c:7803:1: error: bad constant expression
##############################
Test: TestRunner_l2cap-tester - FAIL
Desc: Run l2cap-tester with test-runner
Output:
Total: 96, Passed: 90 (93.8%), Failed: 6, Not Run: 0

Failed Test Cases

L2CAP Ext-Flowctl Server - Nval SCID                 Failed       0.114 seconds
L2CAP Ext-Flowctl Server - PHY 2M/Coded              Failed       0.150 seconds
L2CAP Ext-Flowctl Server - Set PHY 1M                Failed       0.152 seconds
L2CAP Ext-Flowctl Server - Set PHY 2M                Failed       0.160 seconds
L2CAP Ext-Flowctl Server - Set PHY Coded             Failed       0.145 seconds
L2CAP LE EATT Server - Reject                        Failed       0.110 seconds

##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4

Failed Test Cases
Read Exp Feature - Success Failed 0.115 seconds
##############################
Test: TestRunner_sco-tester - FAIL
Desc: Run sco-tester with test-runner
Output:
WARNING: possible circular locking dependency detected

BUG: sleeping function called from invalid context at net/core/sock.c:3782

Total: 30, Passed: 30 (100.0%), Failed: 0, Not Run: 0
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0

Failed Test Cases

Mesh - Send cancel - 1                               Timed out    2.447 seconds
Mesh - Send cancel - 2                               Timed out    1.994 seconds

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth