All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 00/16] Bluetooth: Fixes for issues reported by sashiko.dev
@ 2026-11-17 18:57 Luiz Augusto von Dentz
  2026-11-17 18:57 ` [PATCH v1 01/16] Bluetooth: mgmt: Fix read_index_list() buffer overflow Luiz Augusto von Dentz
                   ` (15 more replies)
  0 siblings, 16 replies; 19+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-17 18:57 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This series fixes issues reported by sashiko.dev against the Bluetooth
core, each patch carries the identifier of the report(s) it addresses in
its Reported-by tag.

Missing locking around shared state:
 - Patch 2 takes hci_req_sync_lock around hci_powered_update_sync() in
   hci_power_on().
 - Patches 3 and 4 look up advertising instances under hdev->lock in
   hci_disable_ext_adv_instance_sync() and
   hci_schedule_adv_instance_sync().
 - Patch 5 serializes the writers of hdev->link_keys. smp_notify_keys()
   runs with the l2cap channel lock held, which is ordered after
   hdev->lock, so this adds a dedicated hdev->link_keys_lock instead of
   taking hdev->lock there.
 - Patch 13 protects the MSFT event prefix with hdev->lock.
 - Patch 15 holds hdev->lock while looking up and freeing advertisement
   monitors.
 - Patch 16 serializes the reparenting of the RFCOMM tty device.

Lifetime issues:
 - Patch 11 reworks the mesh transmission handling: mesh_pending and the
   advertising instances are accessed under hdev->lock, the cmd_sync
   entries carry the transmission handle rather than a pointer to it, and
   Mesh Send Cancel and mgmt_cleanup() cancel a transmission the same
   way, stopping the done timer if it is the one in progress.
 - Patch 12 reads the pending Set Powered command under
   mgmt_pending_lock in mgmt_powering_down().

Missing validation:
 - Patch 1 sizes the Read Index List reply from all the controllers.
 - Patch 6 checks hdev->smp_data before using SMP_DEV().
 - Patch 8 validates the length of the sent LE Set Extended Advertising
   Enable command before parsing it.
 - Patch 9 rejects a zero multi advertising rotation duration.
 - Patch 10 only uses the EFS option in l2cap_parse_conf_rsp() if the
   response carried one.

debugfs:
 - Patch 7 stops force_bredr_smp from creating the BR/EDR SMP channel
   while SMP is not registered.
 - Patch 14 sets/clears the debugfs controlled flags explicitly rather
   than toggling them, and serializes the writers.

Known limitation: in patch 11, if the done timer has already fired when a
transmission is cancelled, mesh_send_done_sync() can still complete the
next transmission early.

Testing: an earlier revision of the series was run with KASAN and lockdep
enabled through the BlueZ testers (mgmt, mesh, smp, l2cap, rfcomm, iso,
...) and test-functional. This revision, rebased on top of bluetooth-next
with patch 11 reworked, has only been build tested (W=1, each patch).

Luiz Augusto von Dentz (16):
  Bluetooth: mgmt: Fix read_index_list() buffer overflow
  Bluetooth: hci_core: Take req_sync lock in hci_power_on()
  Bluetooth: hci_sync: Lock the lookup in
    hci_disable_ext_adv_instance_sync()
  Bluetooth: hci_sync: Hold hdev->lock in
    hci_schedule_adv_instance_sync()
  Bluetooth: SMP: Serialize link key updates from smp_notify_keys()
  Bluetooth: SMP: Check smp_data before using SMP_DEV()
  Bluetooth: SMP: Don't create the BR/EDR channel while unregistered
  Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv
    Enable
  Bluetooth: mgmt: Reject zero multi advertising rotation duration
  Bluetooth: L2CAP: Don't use uninitialized EFS in
    l2cap_parse_conf_rsp()
  Bluetooth: mgmt: Fix mesh transmission locking and lifetime
  Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down()
  Bluetooth: MSFT: Protect the event prefix with hdev->lock
  Bluetooth: hci_debugfs: Fix racy toggling of debugfs controlled flags
  Bluetooth: hci_core: Hold hdev->lock when removing advertisement
    monitors
  Bluetooth: RFCOMM: Serialize tty device reparenting

 include/net/bluetooth/hci_core.h |   4 +
 net/bluetooth/hci_core.c         |  54 ++++++-
 net/bluetooth/hci_debugfs.c      |  30 +++-
 net/bluetooth/hci_event.c        |   9 +-
 net/bluetooth/hci_sync.c         |  24 ++-
 net/bluetooth/l2cap_core.c       |   5 +-
 net/bluetooth/mgmt.c             | 262 +++++++++++++++++++++++++------
 net/bluetooth/mgmt_config.c      |   6 +
 net/bluetooth/msft.c             |  29 ++--
 net/bluetooth/rfcomm/tty.c       |  21 ++-
 net/bluetooth/smp.c              |  58 +++++--
 11 files changed, 406 insertions(+), 96 deletions(-)


base-commit: 3c5963d23d64972385786e0be47be16d89ff4434
-- 
2.56.0


^ permalink raw reply	[flat|nested] 19+ messages in thread
* [PATCH v2 01/17] Bluetooth: mgmt: Fix read_index_list() buffer overflow
@ 2026-11-17 20:20 Luiz Augusto von Dentz
  2026-11-18  2:41 ` Bluetooth: Fixes for issues reported by sashiko.dev bluez.test.bot
  0 siblings, 1 reply; 19+ messages in thread
From: Luiz Augusto von Dentz @ 2026-11-17 20:20 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

The first pass counts only configured controllers, but HCI_UNCONFIGURED
can change before the second pass, which may then write more entries than
were allocated. Size the buffer from the total number of controllers as
read_unconf_index_list() already does.

Reported-by: sashiko.dev (linux-7841362e-9b8f-465f-aa22-e99c315231e2)
Fixes: 73d1df2a7a10 ("Bluetooth: Add support for Read Unconfigured Index List command")
Assisted-by: OpenCode:claude-fable-5.2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 net/bluetooth/mgmt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 6ed3bf6f1738..fc0be4ca033f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -444,10 +444,8 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
 	read_lock(&hci_dev_list_lock);
 
 	count = 0;
-	list_for_each_entry(d, &hci_dev_list, list) {
-		if (!hci_dev_test_flag(d, HCI_UNCONFIGURED))
-			count++;
-	}
+	list_for_each_entry(d, &hci_dev_list, list)
+		count++;
 
 	rp_len = sizeof(*rp) + (2 * count);
 	rp = kmalloc(rp_len, GFP_ATOMIC);
-- 
2.56.0


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

end of thread, other threads:[~2026-11-18  2:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 18:57 [PATCH v1 00/16] Bluetooth: Fixes for issues reported by sashiko.dev Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 01/16] Bluetooth: mgmt: Fix read_index_list() buffer overflow Luiz Augusto von Dentz
2026-11-17 20:13   ` Bluetooth: Fixes for issues reported by sashiko.dev bluez.test.bot
2026-11-17 18:57 ` [PATCH v1 02/16] Bluetooth: hci_core: Take req_sync lock in hci_power_on() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 03/16] Bluetooth: hci_sync: Lock the lookup in hci_disable_ext_adv_instance_sync() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 04/16] Bluetooth: hci_sync: Hold hdev->lock in hci_schedule_adv_instance_sync() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 05/16] Bluetooth: SMP: Serialize link key updates from smp_notify_keys() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 06/16] Bluetooth: SMP: Check smp_data before using SMP_DEV() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 07/16] Bluetooth: SMP: Don't create the BR/EDR channel while unregistered Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 08/16] Bluetooth: hci_event: Validate sent command length in LE Set Ext Adv Enable Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 09/16] Bluetooth: mgmt: Reject zero multi advertising rotation duration Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 10/16] Bluetooth: L2CAP: Don't use uninitialized EFS in l2cap_parse_conf_rsp() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 11/16] Bluetooth: mgmt: Fix mesh transmission locking and lifetime Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 12/16] Bluetooth: MGMT: Fix use-after-free in mgmt_powering_down() Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 13/16] Bluetooth: MSFT: Protect the event prefix with hdev->lock Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 14/16] Bluetooth: hci_debugfs: Fix racy toggling of debugfs controlled flags Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 15/16] Bluetooth: hci_core: Hold hdev->lock when removing advertisement monitors Luiz Augusto von Dentz
2026-11-17 18:57 ` [PATCH v1 16/16] Bluetooth: RFCOMM: Serialize tty device reparenting Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2026-11-17 20:20 [PATCH v2 01/17] Bluetooth: mgmt: Fix read_index_list() buffer overflow Luiz Augusto von Dentz
2026-11-18  2:41 ` Bluetooth: Fixes for issues reported by sashiko.dev bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.