mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_event: Ignore Authentication Complete for non-ACL links
       [not found] <20261130221722.530577-1-deaner92.ref@yahoo.com>
@ 2026-11-30 22:17 ` Jeremy Dean Clifton
  0 siblings, 0 replies; only message in thread
From: Jeremy Dean Clifton @ 2026-11-30 22:17 UTC (permalink / raw)
  To: marcel, luiz.dentz
  Cc: linux-bluetooth, linux-kernel, Jeremy Dean Clifton,
	syzbot+fc4b5b2477d4ca272907

Authentication Complete is only defined for BR/EDR (ACL) links, but
hci_auth_complete_evt() looks the connection up by handle and does not
check its type. If a controller sends the event with the handle of an
LE link, the ACL completion code runs on the LE link.

For an ACL link still in BT_CONFIG, that code drops the reference
hci_conn_complete_evt() took when setup started. An LE link in
BT_CONFIG never took that reference; the one that keeps it alive
during setup belongs to the remote features request started by
hci_le_read_remote_features() and is dropped by
le_read_features_complete(). The event therefore drops a reference the
LE link does not have, and refcnt stays one below the number of
holders. If it reaches zero early, disc_work is queued, and once the
last holder drops its reference, whether le_read_features_complete()
or another user such as an L2CAP channel added by __l2cap_chan_add(),
refcnt goes to -1 and hci_conn_timeout() warns:

  WARNING: net/bluetooth/hci_conn.c:631 at hci_conn_timeout+0x16a/0x230
  Workqueue: hci0 hci_conn_timeout

Before commit a106e50be74b ("Bluetooth: HCI: Add support for LL
Extended Feature Set"), the LE reference was dropped by the LE Read
Remote Features command status and completion handlers, and only while
the link was still in BT_CONFIG, which this event had already cleared,
so the extra drop did not make refcnt negative. That commit moved the
drop to le_read_features_complete(), which drops it unconditionally.

A controller that follows the specification never sends this event
for an LE handle, but the kernel should not corrupt its own state when
one does. Ignore the event for any link type other than ACL before it
changes the connection's state or references. ACL handling is
unchanged.

Tested on arm64 under QEMU with the syzbot C reproducer on
bluetooth-next, with a temporary WARN in hci_conn_drop() when refcnt
goes negative. Without this patch it fired within the first second
(337 times, all on an LE link with handle 0 in BT_CONFIG); with it, it
did not fire in 300 seconds, and the ignored events were logged. The
reproducer sends the event every few milliseconds, and each
hci_conn_hold() cancels disc_work, so the hci_conn_timeout() warning
itself was not seen locally.

Fixes: a106e50be74b ("Bluetooth: HCI: Add support for LL Extended Feature Set")
Reported-by: syzbot+fc4b5b2477d4ca272907@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fc4b5b2477d4ca272907
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jeremy Dean Clifton <deaner92@yahoo.com>
---
 net/bluetooth/hci_event.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index a9b6a6ccaa03..55aa714c4d39 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3684,6 +3684,17 @@ static void hci_auth_complete_evt(struct hci_dev *hdev, void *data,
 	if (!conn)
 		goto unlock;
 
+	/* Authentication Complete is only defined for BR/EDR links. An LE
+	 * link in BT_CONFIG has not taken the reference that the BT_CONFIG
+	 * branch below drops, so letting a misbehaving controller report it
+	 * for an LE handle makes conn->refcnt go negative.
+	 */
+	if (conn->type != ACL_LINK) {
+		bt_dev_err_ratelimited(hdev, "Ignoring Authentication Complete for non-ACL handle 0x%4.4x",
+				       __le16_to_cpu(ev->handle));
+		goto unlock;
+	}
+
 	if (!ev->status) {
 		clear_bit(HCI_CONN_AUTH_FAILURE, conn->flags);
 		set_bit(HCI_CONN_AUTH, conn->flags);
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30 22:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20261130221722.530577-1-deaner92.ref@yahoo.com>
2026-11-30 22:17 ` [PATCH] Bluetooth: hci_event: Ignore Authentication Complete for non-ACL links Jeremy Dean Clifton

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®