* [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
@ 2026-04-05 15:47 Dudu Lu
2026-04-05 16:16 ` bluez.test.bot
2026-04-06 20:40 ` [PATCH] " patchwork-bot+bluetooth
0 siblings, 2 replies; 5+ messages in thread
From: Dudu Lu @ 2026-04-05 15:47 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, luiz.dentz, Dudu Lu
l2cap_ecred_reconf_rsp() calls l2cap_chan_del() without holding
l2cap_chan_lock(). Every other l2cap_chan_del() caller in the file
acquires the lock first. A remote BLE device can send a crafted
L2CAP ECRED reconfiguration response to corrupt the channel list
while another thread is iterating it.
Add l2cap_chan_hold() and l2cap_chan_lock() before l2cap_chan_del(),
and l2cap_chan_unlock() and l2cap_chan_put() after, matching the
pattern used in l2cap_ecred_conn_rsp() and l2cap_conn_del().
Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add L2CAP_ECRED_RECONF support")
Signed-off-by: Dudu Lu <phx0fer@gmail.com>
---
net/bluetooth/l2cap_core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 95c65fece39b..82989c1319c4 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5473,7 +5473,13 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
if (chan->ident != cmd->ident)
continue;
+ l2cap_chan_hold(chan);
+ l2cap_chan_lock(chan);
+
l2cap_chan_del(chan, ECONNRESET);
+
+ l2cap_chan_unlock(chan);
+ l2cap_chan_put(chan);
}
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* RE: Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
2026-04-05 15:47 [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp Dudu Lu
@ 2026-04-05 16:16 ` bluez.test.bot
2026-04-06 20:40 ` [PATCH] " patchwork-bot+bluetooth
1 sibling, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2026-04-05 16:16 UTC (permalink / raw)
To: linux-bluetooth, phx0fer
[-- Attachment #1: Type: text/plain, Size: 2593 bytes --]
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=1077454
---Test result---
Test Summary:
CheckPatch PENDING 0.40 seconds
GitLint PENDING 0.26 seconds
SubjectPrefix PASS 0.10 seconds
BuildKernel PASS 26.57 seconds
CheckAllWarning PASS 29.30 seconds
CheckSparse PASS 27.78 seconds
BuildKernel32 PASS 25.55 seconds
TestRunnerSetup PASS 564.88 seconds
TestRunner_l2cap-tester PASS 27.50 seconds
TestRunner_iso-tester PASS 37.34 seconds
TestRunner_bnep-tester PASS 6.40 seconds
TestRunner_mgmt-tester FAIL 112.72 seconds
TestRunner_rfcomm-tester PASS 9.51 seconds
TestRunner_sco-tester FAIL 14.32 seconds
TestRunner_ioctl-tester PASS 10.22 seconds
TestRunner_mesh-tester FAIL 13.09 seconds
TestRunner_smp-tester PASS 8.60 seconds
TestRunner_userchan-tester PASS 6.70 seconds
IncrementalBuild PENDING 0.48 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
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.103 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.996 seconds
Mesh - Send cancel - 2 Timed out 2.000 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
2026-04-05 15:47 [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp Dudu Lu
2026-04-05 16:16 ` bluez.test.bot
@ 2026-04-06 20:40 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2026-04-06 20:40 UTC (permalink / raw)
To: Dudu Lu; +Cc: linux-bluetooth, marcel, luiz.dentz
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Sun, 5 Apr 2026 23:47:41 +0800 you wrote:
> l2cap_ecred_reconf_rsp() calls l2cap_chan_del() without holding
> l2cap_chan_lock(). Every other l2cap_chan_del() caller in the file
> acquires the lock first. A remote BLE device can send a crafted
> L2CAP ECRED reconfiguration response to corrupt the channel list
> while another thread is iterating it.
>
> Add l2cap_chan_hold() and l2cap_chan_lock() before l2cap_chan_del(),
> and l2cap_chan_unlock() and l2cap_chan_put() after, matching the
> pattern used in l2cap_ecred_conn_rsp() and l2cap_conn_del().
>
> [...]
Here is the summary with links:
- Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
https://git.kernel.org/bluetooth/bluetooth-next/c/ff4aaa2d1db8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
@ 2026-04-03 2:35 Dudu Lu
2026-04-03 5:03 ` bluez.test.bot
0 siblings, 1 reply; 5+ messages in thread
From: Dudu Lu @ 2026-04-03 2:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, luiz.dentz, Dudu Lu
l2cap_ecred_reconf_rsp() calls l2cap_chan_del() without first acquiring
the channel lock or holding a reference on the channel. All other call
sites of l2cap_chan_del() in l2cap_core.c (e.g., l2cap_disconnect_req,
l2cap_ecred_conn_rsp) properly hold the channel lock and a reference.
Without the lock, concurrent operations on the same channel can lead to
list corruption or use-after-free. Fix by adding l2cap_chan_hold +
l2cap_chan_lock before the deletion and the corresponding unlock + put
after, matching the established pattern.
Fixes: 15f02b910562 ("Bluetooth: L2CAP: Add L2CAP_ECRED_RECONF support")
Signed-off-by: Dudu Lu <phx0fer@gmail.com>
---
net/bluetooth/l2cap_core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index XXXXXXX..XXXXXXX 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5472,7 +5472,15 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,
if (chan->ident != cmd->ident)
continue;
- l2cap_chan_del(chan, ECONNRESET);
+ l2cap_chan_hold(chan);
+ l2cap_chan_lock(chan);
+
+ l2cap_chan_del(chan, ECONNRESET);
+
+ l2cap_chan_unlock(chan);
+ l2cap_chan_put(chan);
}
return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
2026-04-03 2:35 Dudu Lu
@ 2026-04-03 5:03 ` bluez.test.bot
2026-04-03 16:19 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 5+ messages in thread
From: bluez.test.bot @ 2026-04-03 5:03 UTC (permalink / raw)
To: linux-bluetooth, phx0fer
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
This is an automated email and please do not reply to this email.
Dear Submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
----- Output -----
error: corrupt patch at line 26
hint: Use 'git am --show-current-patch' to see the failed patch
Please resolve the issue and submit the patches again.
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
2026-04-03 5:03 ` bluez.test.bot
@ 2026-04-03 16:19 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-03 16:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: phx0fer
Hi Dudu,
On Fri, Apr 3, 2026 at 1:03 AM <bluez.test.bot@gmail.com> wrote:
>
> This is an automated email and please do not reply to this email.
>
> Dear Submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.
>
> ----- Output -----
>
> error: corrupt patch at line 26
> hint: Use 'git am --show-current-patch' to see the failed patch
>
> Please resolve the issue and submit the patches again.
>
>
> ---
> Regards,
> Linux Bluetooth
Didn't seem to be properly formatted for git am ingestion, did you use
git format-patch?
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-06 20:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-05 15:47 [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp Dudu Lu
2026-04-05 16:16 ` bluez.test.bot
2026-04-06 20:40 ` [PATCH] " patchwork-bot+bluetooth
-- strict thread matches above, loose matches on Subject: below --
2026-04-03 2:35 Dudu Lu
2026-04-03 5:03 ` bluez.test.bot
2026-04-03 16:19 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox