[PATCH v2 0/2] Bluetooth: Fix advertising instance accesses without hdev->lock

From: Cen Zhang

Date: Wed Nov 18 2026 - 19:33:05 EST


Snapshot advertising instance data under hdev->lock and keep instance
numbers, rather than list pointers, while waiting for controller commands
(patch 1). The resume and power-on walks use a 255-byte stack array in
list order, covering every nonzero u8 instance ID without an allocation
failure after the pause state has been consumed. Widen the timeout
conversion before converting to 10 ms units and clamp to U16_MAX.

Translate management instance numbers to controller handles in the
remaining periodic advertising, BIG creation and advertising set
transfer commands. For the shared handle 0, update the intended instance
after the command succeeds, since the completion has no instance number
(patch 2). The remove-set and random-address paths have already been
fixed in the current tree and keep those implementations.

The former patch 2, "Bluetooth: hci_core: Initialize advertising RPA work
only once", is already applied upstream and is not included again.

Validation: GCC modular and Clang built-in Bluetooth builds, including
Clang context analysis; every prefix of both revised series and their
combined tree build on bluetooth-next f42f5cae154b.
No new kernel runtime test was run; the quoted report is from the earlier
instrumented test kernel.

I used Codex (OpenAI) to help write these patches.

Cen Zhang (2):
Bluetooth: hci_sync: Fix remaining advertising instance UAFs
Bluetooth: hci_sync: Use controller handles for periodic advertising

net/bluetooth/hci_sync.c | 343 ++++++++++++++++++++++++++++++---------
net/bluetooth/mgmt.c | 34 +++-
2 files changed, 292 insertions(+), 85 deletions(-)

---
Changes in v2:
- Address the advertising snapshot allocation and timeout/handle concerns
raised by Sashiko:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/pm-bluetooth-objects-candidate-0245-v9-6b34bc036455ad3dd4ea-0%40gmail.com
- Use a 255-byte stack array in list order, and widen and clamp the duration
conversion.
- Add a separate periodic/BIG/transfer handle mapping fix; retain the
remove-set and random-address fixes already in next.
- Drop the former patch 2, Initialize advertising RPA work only once,
because it is already applied upstream.
- Rebase onto bluetooth-next f42f5cae154b; preserve the connection-work
shutdown changes.

Link to v1: https://lore.kernel.org/r/pm-bluetooth-objects-candidate-0245-v9-6b34bc036455ad3dd4ea-0@xxxxxxxxx