twx-linux/drivers/bluetooth
En-Wei Wu 2e8d44ebaa Bluetooth: btusb: avoid NULL pointer dereference in skb_dequeue()
[ Upstream commit 0317b033abcd1d8dd2798f0e2de5e84543d0bd22 ]

A NULL pointer dereference can occur in skb_dequeue() when processing a
QCA firmware crash dump on WCN7851 (0489:e0f3).

[ 93.672166] Bluetooth: hci0: ACL memdump size(589824)

[ 93.672475] BUG: kernel NULL pointer dereference, address: 0000000000000008
[ 93.672517] Workqueue: hci0 hci_devcd_rx [bluetooth]
[ 93.672598] RIP: 0010:skb_dequeue+0x50/0x80

The issue stems from handle_dump_pkt_qca() returning 0 even when a dump
packet is successfully processed. This is because it incorrectly
forwards the return value of hci_devcd_init() (which returns 0 on
success). As a result, the caller (btusb_recv_acl_qca() or
btusb_recv_evt_qca()) assumes the packet was not handled and passes it
to hci_recv_frame(), leading to premature kfree() of the skb.

Later, hci_devcd_rx() attempts to dequeue the same skb from the dump
queue, resulting in a NULL pointer dereference.

Fix this by:
1. Making handle_dump_pkt_qca() return 0 on success and negative errno
   on failure, consistent with kernel conventions.
2. Splitting dump packet detection into separate functions for ACL
   and event packets for better structure and readability.

This ensures dump packets are properly identified and consumed, avoiding
double handling and preventing NULL pointer access.

Fixes: 20981ce2d5a5 ("Bluetooth: btusb: Add WCN6855 devcoredump support")
Signed-off-by: En-Wei Wu <en-wei.wu@canonical.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-05-09 09:43:57 +02:00
..
ath3k.c Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl 2024-06-27 13:49:02 +02:00
bcm203x.c
bfusb.c
bluecard_cs.c
bpa10x.c
bt3c_cs.c
btbcm.c
btbcm.h
btintel.c Bluetooth: btintel: Direct exception event to bluetooth stack 2024-11-22 15:38:32 +01:00
btintel.h
btmrvl_debugfs.c
btmrvl_drv.h
btmrvl_main.c Bluetooth: HCI: Remove HCI_AMP support 2024-06-12 11:11:55 +02:00
btmrvl_sdio.c Bluetooth: btmrvl: Use IRQF_NO_AUTOEN flag in request_irq() 2024-10-10 11:57:16 +02:00
btmrvl_sdio.h
btmtk.c Bluetooth: btmtk: avoid UAF in btmtk_process_coredump 2024-12-19 18:11:34 +01:00
btmtk.h Bluetooth: btmtk: Add MODULE_FIRMWARE() for MT7922 2024-04-13 13:07:33 +02:00
btmtksdio.c
btmtkuart.c Bluetooth: btmtkuart: fix recv_buf() return value 2024-01-25 15:35:29 -08:00
btnxpuart.c Bluetooth: btnxpuart: Fix glitches seen in dual A2DP streaming 2025-02-08 09:52:31 +01:00
btqca.c Bluetooth: qca: simplify WCN399x NVM loading 2025-04-25 10:45:17 +02:00
btqca.h Bluetooth: qca: fix info leak when fetching fw build id 2024-05-17 12:02:38 +02:00
btqcomsmd.c
btrsi.c Bluetooth: HCI: Remove HCI_AMP support 2024-06-12 11:11:55 +02:00
btrtl.c Bluetooth: btrtl: Prevent potential NULL dereference 2025-04-25 10:45:40 +02:00
btrtl.h
btsdio.c Bluetooth: HCI: Remove HCI_AMP support 2024-06-12 11:11:55 +02:00
btusb.c Bluetooth: btusb: avoid NULL pointer dereference in skb_dequeue() 2025-05-09 09:43:57 +02:00
dtl1_cs.c
h4_recv.h
hci_ag6xx.c
hci_ath.c
hci_bcm4377.c Bluetooth: hci_bcm4377: Use correct unit for timeouts 2024-08-03 08:53:44 +02:00
hci_bcm.c
hci_bcsp.c
hci_h4.c
hci_h5.c Bluetooth: btrtl: fix out of bounds memory access 2024-03-26 18:19:38 -04:00
hci_intel.c
hci_ldisc.c Bluetooth: hci_uart: Fix another race during initialization 2025-04-25 10:45:37 +02:00
hci_ll.c
hci_mrvl.c
hci_nokia.c
hci_qca.c Bluetooth: qca: If memdump doesn't work, re-enable IBS 2024-09-12 11:11:33 +02:00
hci_serdev.c Bluetooth: HCI: Remove HCI_AMP support 2024-06-12 11:11:55 +02:00
hci_uart.h Bluetooth: hci_uart: Fix another race during initialization 2025-04-25 10:45:37 +02:00
hci_vhci.c Bluetooth: vhci: Avoid needless snprintf() calls 2025-04-25 10:45:47 +02:00
Kconfig
Makefile
virtio_bt.c Bluetooth: HCI: Remove HCI_AMP support 2024-06-12 11:11:55 +02:00