Bluetooth: vhci: Prevent use-after-free by removing debugfs files early
authorIvan Pravdin <ipravdin.official@gmail.com>
Wed, 27 Aug 2025 14:53:25 +0000 (10:53 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 29 Aug 2025 18:47:20 +0000 (14:47 -0400)
commit28010791193a4503f054e8d69a950ef815deb539
tree9c2e49514e45417616f4f8a7c443a52edc8cbab2
parent5189446ba995556eaa3755a6e875bc06675b88bd
Bluetooth: vhci: Prevent use-after-free by removing debugfs files early

Move the creation of debugfs files into a dedicated function, and ensure
they are explicitly removed during vhci_release(), before associated
data structures are freed.

Previously, debugfs files such as "force_suspend", "force_wakeup", and
others were created under hdev->debugfs but not removed in
vhci_release(). Since vhci_release() frees the backing vhci_data
structure, any access to these files after release would result in
use-after-free errors.

Although hdev->debugfs is later freed in hci_release_dev(), user can
access files after vhci_data is freed but before hdev->debugfs is
released.

Fixes: ab4e4380d4e1 ("Bluetooth: Add vhci devcoredump support")
Signed-off-by: Ivan Pravdin <ipravdin.official@gmail.com>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/hci_vhci.c