]> git.ipfire.org Git - thirdparty/linux.git/commit
Bluetooth: hci_sync: annotate data-races around hdev->req_status
authorCen Zhang <zzzccc427@gmail.com>
Sun, 15 Mar 2026 12:07:26 +0000 (20:07 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 19 Mar 2026 18:43:20 +0000 (14:43 -0400)
commitb6807cfc195ef99e1ac37b2e1e60df40295daa8c
tree58a47a756fdc95b9f07b4fcfde36f0c57cdae562
parent5f5fa4cd35f707344f65ce9e225b6528691dbbaa
Bluetooth: hci_sync: annotate data-races around hdev->req_status

__hci_cmd_sync_sk() sets hdev->req_status under hdev->req_lock:

    hdev->req_status = HCI_REQ_PEND;

However, several other functions read or write hdev->req_status without
holding any lock:

  - hci_send_cmd_sync() reads req_status in hci_cmd_work (workqueue)
  - hci_cmd_sync_complete() reads/writes from HCI event completion
  - hci_cmd_sync_cancel() / hci_cmd_sync_cancel_sync() read/write
  - hci_abort_conn() reads in connection abort path

Since __hci_cmd_sync_sk() runs on hdev->req_workqueue while
hci_send_cmd_sync() runs on hdev->workqueue, these are different
workqueues that can execute concurrently on different CPUs. The plain
C accesses constitute a data race.

Add READ_ONCE()/WRITE_ONCE() annotations on all concurrent accesses
to hdev->req_status to prevent potential compiler optimizations that
could affect correctness (e.g., load fusing in the wait_event
condition or store reordering).

Signed-off-by: Cen Zhang <zzzccc427@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/hci_conn.c
net/bluetooth/hci_core.c
net/bluetooth/hci_sync.c