Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v4 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.
--- net/bluetooth/l2cap_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +9 -1
@@ -5055,7 +5055,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn,u16 mtu, mps;__le16 psm;u8 result, rsp_len =0 ; -int i, num_scid; +int i, num_scid =0 ;bool defer = false;if (!enable_ecred)
@@ -5068,6 +5068,14 @@ 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, + &num_scid); +if (num_scid) { + result =L2CAP_CR_LE_INVALID_PARAMS ; + goto response; + } + cmd_len -=sizeof (*req); num_scid = cmd_len /sizeof (u16);
Signature · 1 line
2.53.0
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=1064660
---Test result---
Test Summary:
CheckPatch PENDING 0.43 seconds GitLint PENDING 0.30 seconds SubjectPrefix PASS 4.04 seconds BuildKernel PASS 26.54 seconds CheckAllWarning PASS 29.00 seconds CheckSparse WARNING 33.02 seconds BuildKernel32 PASS 25.70 seconds TestRunnerSetup PASS 570.95 seconds TestRunner_l2cap-tester PASS 29.04 seconds TestRunner_iso-tester PASS 83.16 seconds TestRunner_bnep-tester PASS 6.46 seconds TestRunner_mgmt-tester FAIL 115.86 seconds TestRunner_rfcomm-tester PASS 9.78 seconds TestRunner_sco-tester FAIL 14.63 seconds TestRunner_ioctl-tester PASS 10.28 seconds TestRunner_mesh-tester FAIL 11.48 seconds TestRunner_smp-tester PASS 8.75 seconds TestRunner_userchan-tester PASS 6.67 seconds IncrementalBuild PENDING 0.65 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:7796:1: error: bad constant expressionnet/bluetooth/l2cap_core.c:7797:1: error: bad constant expressionnet/bluetooth/l2cap_core.c:7799:1: error: bad constant expressionnet/bluetooth/l2cap_core.c:7800:1: error: bad constant expression
##############################
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.106 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 1.846 seconds Mesh - Send cancel - 2 Timed out 1.998 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Tue, 10 Mar 2026 17:40:37 -0400 you wrote:
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 thanL2CAP_ECRED_MAX_CID(5)to be allocated inl2cap_ecred_rsp_defercausing an overflow.[...]
Here is the summary with links:
- [v4] Bluetooth: L2CAP: Fix accepting multiple L2CAP_ECRED_CONN_REQ
https://git.kernel.org/bluetooth/bluetooth-next/c/19ba9c64840d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html