public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Dudu Lu <phx0fer@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, luiz.dentz@gmail.com, Dudu Lu <phx0fer@gmail.com>
Subject: [PATCH] Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
Date: Fri,  3 Apr 2026 10:35:13 +0800	[thread overview]
Message-ID: <20260403023513.25151-1-phx0fer@gmail.com> (raw)

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;

             reply	other threads:[~2026-04-03  2:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03  2:35 Dudu Lu [this message]
2026-04-03  5:03 ` Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260403023513.25151-1-phx0fer@gmail.com \
    --to=phx0fer@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox