Public bug reported: [Impact]
On Ubuntu 26.04 (bluez 5.85-4ubuntu0.4, amd64) bluetoothd crashes when a GATT client calls StartNotify and the LE peripheral disconnects before the CCC write completes. systemd restarts bluetoothd, but every D-Bus client loses its device and GATT objects, so applications that keep a connection or cache GATT paths (e.g. Home Assistant through bleak) stop working until they are restarted. I see this with Home Assistant controlling a Bluetooth LE door lock that drops the connection by itself right after an operation. bluetoothd crashed three times in three weeks after upgrading from 24.04 (bluez 5.72), where I had not seen this crash: kernel: bluetoothd[997]: segfault at 31 ip 00005b361ecf4fff sp 00007ffc93d28330 error 4 in bluetoothd[cefff,5b361ec4a000+107000] kernel: bluetoothd[1966839]: segfault at 31 ip 000062fa8302afff sp 00007ffdc87a3930 error 4 in bluetoothd[cefff,62fa82f80000+107000] bluetoothd[1209223]: dbus[1209223]: arguments to dbus_message_get_no_reply() were incorrect, assertion "message != NULL" failed in file ../../dbus/dbus-message.c line 3268. systemd[1]: bluetooth.service: Main process exited, code=killed, status=6/ABRT The SIGABRT message is identical to the one in the upstream report https://github.com/bluez/bluez/issues/2538 (bluez 5.87, backtrace: async_dbus_op_reply <- enable_ccc_callback <- disconnect_cb). When enabling notifications fails, register_notify_cb() frees the notify client, which frees the pending operation, and then replies to that freed operation. Upstream fixed this in: https://github.com/bluez/bluez/commit/65f8a8b60a70143c37527280278c462aa5a11bfc "shared/gatt-client: Fix calling destroy after unregistering notify" It is included in bluez 5.88 (already in Debian sid and in the Ubuntu development series) and applies cleanly to 5.85-4ubuntu0.4. I'd like to ask for this commit to be backported to resolute. [Test Plan] The crash depends on timing, so there is no fully deterministic reproducer: 1. Connect to an LE peripheral that supports notifications or indications (bluetoothctl: connect, then gatt.select-attribute <characteristic>). 2. Run "notify on" and make the peripheral drop the link before the CCC write completes (power it off, or use a device that disconnects by itself). 3. Without the fix, bluetoothd may crash (SIGSEGV or SIGABRT as above). With the fix, StartNotify returns an error to the caller and bluetoothd keeps running. In practice: run a GATT client that repeatedly connects and calls StartNotify on a device that disconnects shortly after connecting, and check `journalctl -u bluetooth` for crashes over several days. [Where problems could occur] The patch changes when the destroy callback of a notification registration runs (now when unregistering instead of when the last reference to notify_data is dropped), and the order of the reply and the cleanup in register_notify_cb(). Regressions would show up in GATT notification users in bluetoothd, e.g. HID over GATT (HoG), or in D-Bus clients that call StartNotify/StopNotify. The same change has been in upstream since September 2026 and is part of the 5.88 release. [Other Info] Hardware: Realtek RTL8761BU USB adapter (TP-Link UB500), kernel 7.0.0-42-generic. ** Affects: bluez (Ubuntu) Importance: Undecided Status: New -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2176106 Title: bluetoothd crashes when an LE device disconnects while StartNotify is pending (fixed upstream in 65f8a8b60a) To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bluez/+bug/2176106/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
