mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: L2CAP: Keep recvmsg from resuming a closed channel
@ 2026-11-09 13:21 Zhao Li
  2026-11-09 23:00 ` patchwork-bot+bluetooth
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Li @ 2026-11-09 13:21 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz
  Cc: Mat Martineau, Gustavo Padovan, security, linux-bluetooth,
	linux-kernel, stable

Reading buffered ERTM data after ACL link loss can clear local busy and
send a supervisory frame after l2cap_conn_del() has destroyed the HCI
channel, which oopses on a NULL pointer in hci_send_acl(). The socket still
owns its L2CAP channel, so its lifetime does not protect the underlying HCI
channel.

Require BT_CONNECTED before clearing local busy in recvmsg. The socket lock
already held here serializes this check and send with teardown, which
closes the socket before the HCI channel is destroyed. Continue to allow
buffered data to be read after disconnection.

AI assistance was used.

Fixes: 61aa4f5b9f43 ("Bluetooth: Use the transmit state machine for busy state changes")
Cc: stable@vger.kernel.org # needs adjustments for 5.15
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
No new W=1 GCC/Clang, sparse or smatch warnings.

In QEMU/vhci with KASAN, the base kernel faulted in hci_send_acl() during
busy-clear after the link was dropped, in two boots; the patched kernel ran
31 rounds that reached that state (RNR sent, slow reads, link loss) without
a report.

 net/bluetooth/l2cap_sock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 7a2551ef7f50..e5c15c083c1a 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -1332,7 +1332,8 @@ static int l2cap_sock_recvmsg(struct socket *sock, struct msghdr *msg,
 	 * available.  This avoids resending large numbers of
 	 * frames.
 	 */
-	if (test_bit(CONN_LOCAL_BUSY, &pi->chan->conn_state) &&
+	if (sk->sk_state == BT_CONNECTED &&
+	    test_bit(CONN_LOCAL_BUSY, &pi->chan->conn_state) &&
 	    atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf >> 1)
 		l2cap_chan_busy(pi->chan, 0);
 

base-commit: 6b4b543fa18757297ac756a6fe6e64f506b7844a
-- 
2.56.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Bluetooth: L2CAP: Keep recvmsg from resuming a closed channel
  2026-11-09 13:21 [PATCH] Bluetooth: L2CAP: Keep recvmsg from resuming a closed channel Zhao Li
@ 2026-11-09 23:00 ` patchwork-bot+bluetooth
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2026-11-09 23:00 UTC (permalink / raw)
  To: Zhao Li
  Cc: marcel, luiz.dentz, martineau, gustavo, security,
	linux-bluetooth, linux-kernel, stable

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon,  9 Nov 2026 21:21:43 +0800 you wrote:
> Reading buffered ERTM data after ACL link loss can clear local busy and
> send a supervisory frame after l2cap_conn_del() has destroyed the HCI
> channel, which oopses on a NULL pointer in hci_send_acl(). The socket still
> owns its L2CAP channel, so its lifetime does not protect the underlying HCI
> channel.
> 
> Require BT_CONNECTED before clearing local busy in recvmsg. The socket lock
> already held here serializes this check and send with teardown, which
> closes the socket before the HCI channel is destroyed. Continue to allow
> buffered data to be read after disconnection.
> 
> [...]

Here is the summary with links:
  - Bluetooth: L2CAP: Keep recvmsg from resuming a closed channel
    https://git.kernel.org/bluetooth/bluetooth-next/c/1f2ac56137c5

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] 2+ messages in thread

end of thread, other threads:[~2026-11-09 23:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 13:21 [PATCH] Bluetooth: L2CAP: Keep recvmsg from resuming a closed channel Zhao Li
2026-11-09 23:00 ` 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

all inboxes | Powered by JetHome®