linux/drivers/bluetooth
Jia-Hong Su 0c3cd7a0b8 Bluetooth: hci_uart: fix null-ptr-deref in hci_uart_write_work
hci_uart_set_proto() sets HCI_UART_PROTO_INIT before calling
hci_uart_register_dev(), which calls proto->open() to initialize
hu->priv. However, if a TTY write wakeup occurs during this window,
hci_uart_tx_wakeup() may schedule write_work before hu->priv is
initialized, leading to a NULL pointer dereference in
hci_uart_write_work() when proto->dequeue() accesses hu->priv.

The race condition is:

  CPU0                              CPU1
  ----                              ----
  hci_uart_set_proto()
    set_bit(HCI_UART_PROTO_INIT)
    hci_uart_register_dev()
                                    tty write wakeup
                                      hci_uart_tty_wakeup()
                                        hci_uart_tx_wakeup()
                                          schedule_work(&hu->write_work)
      proto->open(hu)
        // initializes hu->priv
                                    hci_uart_write_work()
                                      hci_uart_dequeue()
                                        proto->dequeue(hu)
                                          // accesses hu->priv (NULL!)

Fix this by moving set_bit(HCI_UART_PROTO_INIT) after proto->open()
succeeds, ensuring hu->priv is initialized before any work can be
scheduled.

Fixes: 5df5dafc17 ("Bluetooth: hci_uart: Fix another race during initialization")
Link: https://lore.kernel.org/linux-bluetooth/6969764f.170a0220.2b9fc4.35a7@mx.google.com/

Signed-off-by: Jia-Hong Su <s11242586@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2026-01-22 13:22:22 -05:00
..
Kconfig Bluetooth: hci_h5: implement CRC data integrity 2025-12-01 15:58:54 -05:00
Makefile
ath3k.c
bcm203x.c
bfusb.c
bluecard_cs.c
bpa10x.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
bt3c_cs.c
btbcm.c drivers/bluetooth: btbcm: Use kmalloc_array() to prevent overflow 2025-12-01 16:21:16 -05:00
btbcm.h
btintel.c Bluetooth: btintel: Add support for BlazarIW core 2025-09-27 11:36:59 -04:00
btintel.h
btintel_pcie.c Bluetooth: btintel_pcie: Introduce HCI Driver protocol 2025-12-01 16:04:51 -05:00
btintel_pcie.h Bluetooth: btintel_pcie: Suspend/Resume: Controller doorbell interrupt handling 2025-12-01 16:00:07 -05:00
btmrvl_debugfs.c
btmrvl_drv.h
btmrvl_main.c
btmrvl_sdio.c
btmrvl_sdio.h
btmtk.c
btmtk.h
btmtksdio.c Bluetooth: Remove redundant pm_runtime_mark_last_busy() calls 2025-12-01 16:00:07 -05:00
btmtkuart.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
btnxpuart.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
btqca.c
btqca.h
btqcomsmd.c
btrsi.c
btrtl.c Bluetooth: btrtl: Add the support for RTL8761CUV 2025-12-01 16:00:07 -05:00
btrtl.h
btsdio.c
btusb.c Bluetooth: btusb: revert use of devm_kzalloc in btusb 2025-12-19 17:23:18 -05:00
dtl1_cs.c
hci_ag6xx.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_aml.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_ath.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_bcm.c Bluetooth: Remove redundant pm_runtime_mark_last_busy() calls 2025-12-01 16:00:07 -05:00
hci_bcm4377.c
hci_bcsp.c Bluetooth: bcsp: receive data only if registered 2025-09-27 11:37:02 -04:00
hci_h4.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_h5.c Bluetooth: Remove redundant pm_runtime_mark_last_busy() calls 2025-12-01 16:00:07 -05:00
hci_intel.c Bluetooth: Remove redundant pm_runtime_mark_last_busy() calls 2025-12-01 16:00:07 -05:00
hci_ldisc.c Bluetooth: hci_uart: fix null-ptr-deref in hci_uart_write_work 2026-01-22 13:22:22 -05:00
hci_ll.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_mrvl.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_nokia.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_qca.c Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_serdev.c
hci_uart.h Bluetooth: fix corruption in h4_recv_buf() after cleanup 2025-10-24 10:31:24 -04:00
hci_vhci.c Bluetooth: vhci: Prevent use-after-free by removing debugfs files early 2025-08-29 14:47:20 -04:00
virtio_bt.c