* [PATCH] Bluetooth: hci_vhci: Pin module for debugfs file operations
@ 2026-10-08 4:54 Bui Viet Dung
2026-10-08 8:09 ` bluez.test.bot
2026-10-09 14:20 ` [PATCH] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Bui Viet Dung @ 2026-10-08 4:54 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz
Cc: Ivan Pravdin, Paul Menzel, linux-bluetooth, linux-kernel, stable,
Bui Viet Dung
An open debugfs file retains its file_operations pointer in the
debugfs proxy state. However, force_suspend_fops, force_wakeup_fops,
aosp_capable_fops, and force_devcoredump_fops have no .owner set to
THIS_MODULE. As a result, full_proxy_open_regular() calls fops_get()
which succeeds without taking a reference to the hci_vhci module.
When userspace opens any of these debugfs files and later closes
the /dev/vhci file descriptor (triggering vhci_release() and
debugfs file removal), the open debugfs file descriptor remains valid
in userspace. Because the module refcount was not incremented,
the hci_vhci module can be unloaded via delete_module (rmmod hci_vhci).
When the userspace process subsequently closes the debugfs file
descriptor, full_proxy_release() accesses the already unmapped
file_operations structure, resulting in a kernel page fault / oops:
BUG: unable to handle page fault for address: fffffbfff846f18b
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
Oops: Oops: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:full_proxy_release+0x8e/0x140
Call Trace:
<TASK>
__fput+0x39f/0xa60
fput_close_sync+0xff/0x200
__x64_sys_close+0x8c/0xf0
do_syscall_64+0xc3/0x590
entry_SYSCALL_64_after_hwframe+0x76/0x7e
</TASK>
Modules linked in: ... [last unloaded: hci_vhci(E)]
The issue was discovered via manual code audit of
drivers/bluetooth/hci_vhci.c and verified on a Linux 7.3-rc6 test VM
with CONFIG_BT_VHCI=m by keeping a debugfs file open across controller
teardown and module unload.
Set .owner = THIS_MODULE on all four file_operations structures so that
debugfs pins the module until all file descriptors are closed.
Fixes: 28010791193a ("Bluetooth: vhci: Prevent use-after-free by removing debugfs files early")
Cc: stable@vger.kernel.org
Signed-off-by: Bui Viet Dung <dungvn2345@gmail.com>
---
drivers/bluetooth/hci_vhci.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index eddb32b30539..8f7db0102b25 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -155,6 +155,7 @@ static ssize_t force_suspend_write(struct file *file,
}
static const struct file_operations force_suspend_fops = {
+ .owner = THIS_MODULE,
.open = simple_open,
.read = force_suspend_read,
.write = force_suspend_write,
@@ -194,6 +195,7 @@ static ssize_t force_wakeup_write(struct file *file,
}
static const struct file_operations force_wakeup_fops = {
+ .owner = THIS_MODULE,
.open = simple_open,
.read = force_wakeup_read,
.write = force_wakeup_write,
@@ -263,6 +265,7 @@ static ssize_t aosp_capable_write(struct file *file,
}
static const struct file_operations aosp_capable_fops = {
+ .owner = THIS_MODULE,
.open = simple_open,
.read = aosp_capable_read,
.write = aosp_capable_write,
@@ -386,6 +389,7 @@ static ssize_t force_devcd_write(struct file *file, const char __user *user_buf,
}
static const struct file_operations force_devcoredump_fops = {
+ .owner = THIS_MODULE,
.open = simple_open,
.write = force_devcd_write,
};
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: Bluetooth: hci_vhci: Pin module for debugfs file operations
2026-10-08 4:54 [PATCH] Bluetooth: hci_vhci: Pin module for debugfs file operations Bui Viet Dung
@ 2026-10-08 8:09 ` bluez.test.bot
2026-10-09 14:20 ` [PATCH] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-10-08 8:09 UTC (permalink / raw)
To: linux-bluetooth, dungvn2345
[-- Attachment #1: Type: text/plain, Size: 1605 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1181255/
---Test result---
Test Summary:
CheckPatch PASS 1.62 seconds
VerifyFixes PASS 0.07 seconds
VerifySignedoff PASS 0.07 seconds
GitLint PASS 0.22 seconds
SubjectPrefix PASS 0.06 seconds
BuildKernel PASS 29.09 seconds
CheckAllWarning PASS 34.18 seconds
CheckSparse PASS 36.46 seconds
BuildKernel32 PASS 29.43 seconds
CheckKernelLLVM PASS 35.02 seconds
TestRunnerSetup PASS 785.49 seconds
TestRunner_l2cap-tester PASS 12.60 seconds
TestRunner_iso-tester PASS 16.71 seconds
TestRunner_bnep-tester PASS 3.08 seconds
TestRunner_mgmt-tester PASS 61.03 seconds
TestRunner_rfcomm-tester PASS 9.23 seconds
TestRunner_sco-tester PASS 5.63 seconds
TestRunner_ioctl-tester PASS 4.63 seconds
TestRunner_mesh-tester PASS 5.47 seconds
TestRunner_smp-tester PASS 4.28 seconds
TestRunner_userchan-tester PASS 3.15 seconds
TestRunner_6lowpan-tester PASS 4.36 seconds
IncrementalBuild PASS 28.72 seconds
https://github.com/bluez/bluetooth-next/pull/882
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Bluetooth: hci_vhci: Pin module for debugfs file operations
2026-10-08 4:54 [PATCH] Bluetooth: hci_vhci: Pin module for debugfs file operations Bui Viet Dung
2026-10-08 8:09 ` bluez.test.bot
@ 2026-10-09 14:20 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-10-09 14:20 UTC (permalink / raw)
To: Bui Viet Dung
Cc: marcel, luiz.dentz, ipravdin.official, pmenzel, linux-bluetooth,
linux-kernel, stable
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Thu, 8 Oct 2026 11:54:13 +0700 you wrote:
> An open debugfs file retains its file_operations pointer in the
> debugfs proxy state. However, force_suspend_fops, force_wakeup_fops,
> aosp_capable_fops, and force_devcoredump_fops have no .owner set to
> THIS_MODULE. As a result, full_proxy_open_regular() calls fops_get()
> which succeeds without taking a reference to the hci_vhci module.
>
> When userspace opens any of these debugfs files and later closes
> the /dev/vhci file descriptor (triggering vhci_release() and
> debugfs file removal), the open debugfs file descriptor remains valid
> in userspace. Because the module refcount was not incremented,
> the hci_vhci module can be unloaded via delete_module (rmmod hci_vhci).
>
> [...]
Here is the summary with links:
- Bluetooth: hci_vhci: Pin module for debugfs file operations
https://git.kernel.org/bluetooth/bluetooth-next/c/da8aab8ed08d
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-09 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-08 4:54 [PATCH] Bluetooth: hci_vhci: Pin module for debugfs file operations Bui Viet Dung
2026-10-08 8:09 ` bluez.test.bot
2026-10-09 14:20 ` [PATCH] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox