Linux bluetooth development
 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
  2026-12-01  6:52   ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages 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 related	[flat|nested] 2+ messages in thread

* RE: Bluetooth: hci_event: Ignore Authentication Complete for non-ACL links
  2026-11-30 22:17 ` [PATCH] Bluetooth: hci_event: Ignore Authentication Complete for non-ACL links Jeremy Dean Clifton
@ 2026-12-01  6:52   ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-12-01  6:52 UTC (permalink / raw)
  To: linux-bluetooth, deaner92

[-- Attachment #1: Type: text/plain, Size: 2658 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/series/1227360/

---Test result---

Test Summary:
CheckPatch                    FAIL      0.57 seconds
VerifyFixes                   PASS      0.10 seconds
VerifySignedoff               PASS      0.10 seconds
GitLint                       PASS      0.27 seconds
SubjectPrefix                 PASS      0.09 seconds
BuildKernel                   PASS      18.49 seconds
CheckAllWarning               PASS      22.04 seconds
CheckSparse                   WARNING   23.45 seconds
BuildKernel32                 PASS      19.57 seconds
CheckKernelLLVM               PASS      19.35 seconds
TestRunnerSetup               PASS      403.43 seconds
TestRunner_l2cap-tester       PASS      15.11 seconds
TestRunner_iso-tester         PASS      11.32 seconds
TestRunner_bnep-tester        PASS      3.00 seconds
TestRunner_mgmt-tester        PASS      85.18 seconds
TestRunner_rfcomm-tester      PASS      4.04 seconds
TestRunner_sco-tester         PASS      5.09 seconds
TestRunner_ioctl-tester       PASS      4.36 seconds
TestRunner_mesh-tester        PASS      4.18 seconds
TestRunner_smp-tester         PASS      4.03 seconds
TestRunner_userchan-tester    PASS      2.95 seconds
TestRunner_6lowpan-tester     PASS      4.08 seconds
IncrementalBuild              PASS      18.59 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
Bluetooth: hci_event: Ignore Authentication Complete for non-ACL links
WARNING: Non-standard signature: Assisted-by:
#164: 
Assisted-by: Claude:claude-opus-5-5

ERROR: Unrecognized email address: 'Claude:claude-opus-5-5'
#164: 
Assisted-by: Claude:claude-opus-5-5

total: 1 errors, 1 warnings, 0 checks, 17 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

/home/runner/work/bluetooth-next/bluetooth-next/src/patch/15039405.patch has style problems, please review.

NOTE: Ignored message types: UNKNOWN_COMMIT_ID

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
net/bluetooth/hci_event.c: note: in included file (through include/net/bluetooth/hci_core.h):


https://github.com/bluez/bluetooth-next/pull/1263

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-12-01  6:52 UTC | newest]

Thread overview: 2+ messages (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
2026-12-01  6:52   ` bluez.test.bot

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