public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [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 [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp 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

* [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
@ 2026-04-05 15:47 Dudu Lu
  2026-04-06 20:40 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 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: [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
  2026-04-05 15:47 [PATCH] " Dudu Lu
@ 2026-04-06 20:40 ` patchwork-bot+bluetooth
  0 siblings, 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

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-03  2:35 [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp Dudu Lu
2026-04-03  5:03 ` bluez.test.bot
2026-04-03 16:19   ` Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2026-04-05 15:47 [PATCH] " Dudu Lu
2026-04-06 20:40 ` patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox