[bluez/bluez] 63414d: device: Limit the number of retries on auth failures

From: Andrey Smirnov <hidden>
Date: 2025-11-11 21:32:02

  Branch: refs/heads/1022224
  Home:   https://github.com/bluez/bluez
  Commit: 63414df576baf22d460f974b670299a98b2e000e
      https://github.com/bluez/bluez/commit/63414df576baf22d460f974b670299a98b2e000e
  Author: Andrey Smirnov [off-list ref]
  Date:   2025-11-11 (Tue, 11 Nov 2025)

  Changed paths:
    M src/device.c

  Log Message:
  -----------
  device: Limit the number of retries on auth failures

Currently BlueZ has no retry limit on reconnection attempts in case of
authentication failures. This leads to a very unpleasant user
experince with, for example, XBox controller. The scenario is as
follows:

1. Host A is running BlueZ and XBox controller is paired and connected
   to it.
2. Host A shuts down (for example)
3. XBox controller is put into pairing mode and is paired to a Host B
4. Host B is powered down
5. Host A is powered on
6. XBox controller is powered on
7. Host A/BlueZ will start spamming XBox controller with connection
   attempts in an endless loop

What happens under the hood is:

1. BlueZ starts up, sees that there's LTK saved for XBox controller,
   so it adds it to kernels autoconnect list
2. Once XBox controller is on and advertising, kernel connects to it
3. BlueZ tries to elevate the security level, but is rejected by the
   controller with "Key or PIN missing" because the controller is already
   paired to another host.
4. Controller disconnects, controller goes back to advertising, goto 2

To avoid this, let's add a simple auth failure counter and disable
autoconnect for the device once we go past the failure threshold.



To unsubscribe from these emails, change your notification settings at https://github.com/bluez/bluez/settings/notifications
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help