* [PATCH v2] Bluetooth: RFCOMM: serialize session teardown
@ 2026-08-22 15:06 Chengfeng Ye
2026-08-22 15:44 ` [v2] " bluez.test.bot
2026-08-24 16:50 ` [PATCH v2] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Chengfeng Ye @ 2026-08-22 15:06 UTC (permalink / raw)
To: Marcel Holtmann, Luiz Augusto von Dentz, Kees Cook, Chengfeng Ye,
Jakub Kicinski, Pengpeng Hou, Jiale Yao, SeungJu Cheon,
Ali Ahmet Memis, Tim Bird
Cc: linux-bluetooth, linux-kernel, Pauli Virtanen
rfcomm_kill_listener() walks session_list and deletes every session
without holding rfcomm_mutex, unlike the normal session processing and
connect error paths.
Under normal operation, an open RFCOMM socket pins rfcomm.ko, so
rfcomm_kill_listener() does not run concurrently with rfcomm_dlc_open().
However, forced module unload via delete_module(O_TRUNC) can stop
krfcommd while a failed connect is still unwinding.
connect task forced unload / krfcommd
------------ ------------------------
rfcomm_lock()
rfcomm_session_add()
delete_module("rfcomm", O_TRUNC)
rfcomm_kill_listener()
fetch session from session_list
kernel_connect() fails
rfcomm_session_del()
remove and free session
rfcomm_session_del(session)
The final call then reads the freed session and may corrupt the list.
KASAN reported with mdelay() to enlarge critical window:
BUG: KASAN: slab-use-after-free in rfcomm_run+0x3802/0x3f00 [rfcomm]
Read of size 8 at addr ffff888111058d40 by task krfcommd/79
Tainted: [R]=FORCED_RMMOD
Allocated by task 86:
rfcomm_session_add+0xa1/0x300 [rfcomm]
rfcomm_dlc_open+0x8b2/0xf30 [rfcomm]
rfcomm_sock_connect+0x34c/0x530 [rfcomm]
Freed by task 86:
kfree+0x121/0x3c0
rfcomm_dlc_open+0xab7/0xf30 [rfcomm]
rfcomm_sock_connect+0x34c/0x530 [rfcomm]
Hold rfcomm_mutex across the teardown traversal so every reachable
session_list walk uses the same serialization.
Reviewed-by: Ali Ahmet Memis <ali@iusegentoo.com>
Tested-by: Ali Ahmet Memis <ali@iusegentoo.com>
Reviewed-by: Pauli Virtanen <pav@iki.fi>
Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
---
Changes in v2:
- Rewrite the changelog to describe make clear trigger: forced module
unload with delete_module(O_TRUNC) and temporary delay widening.
- Drop the Fixes tag.
- Drop Cc: stable.
- Add Ali Ahmet Memis's Reviewed-by and Tested-by tags.
- Add Pauli Virtanen's Reviewed-by tag.
Link: https://lkml.iu.edu/2608.2/10891.html [v1]
net/bluetooth/rfcomm/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 9cdfea666a2c..5fe2758e8c47 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2178,8 +2178,10 @@ static void rfcomm_kill_listener(void)
BT_DBG("");
+ rfcomm_lock();
list_for_each_entry_safe(s, n, &session_list, list)
rfcomm_session_del(s);
+ rfcomm_unlock();
}
static int rfcomm_run(void *unused)
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [v2] Bluetooth: RFCOMM: serialize session teardown
2026-08-22 15:06 [PATCH v2] Bluetooth: RFCOMM: serialize session teardown Chengfeng Ye
@ 2026-08-22 15:44 ` bluez.test.bot
2026-08-24 16:50 ` [PATCH v2] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-08-22 15:44 UTC (permalink / raw)
To: linux-bluetooth, nicoyip.dev
[-- Attachment #1: Type: text/plain, Size: 1921 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/project/bluetooth/list/?series=1150209
---Test result---
Test Summary:
CheckPatch FAIL 0.50 seconds
VerifyFixes PASS 0.10 seconds
VerifySignedoff PASS 0.10 seconds
GitLint PASS 0.24 seconds
SubjectPrefix PASS 0.10 seconds
BuildKernel PASS 19.49 seconds
CheckAllWarning PASS 20.25 seconds
CheckSparse PASS 20.09 seconds
BuildKernel32 PASS 17.78 seconds
CheckKernelLLVM SKIP 0.00 seconds
TestRunnerSetup PASS 312.51 seconds
TestRunner_rfcomm-tester PASS 18.63 seconds
IncrementalBuild PASS 18.67 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v2] Bluetooth: RFCOMM: serialize session teardown
WARNING: The commit message has 'BUG: KASAN: ', perhaps it also needs a 'Fixes:' tag?
total: 0 errors, 1 warnings, 0 checks, 10 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/patch/14763029.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found
https://github.com/bluez/bluetooth-next/pull/635
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] Bluetooth: RFCOMM: serialize session teardown
2026-08-22 15:06 [PATCH v2] Bluetooth: RFCOMM: serialize session teardown Chengfeng Ye
2026-08-22 15:44 ` [v2] " bluez.test.bot
@ 2026-08-24 16:50 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-08-24 16:50 UTC (permalink / raw)
To: Chengfeng Ye
Cc: marcel, luiz.dentz, kees, kuba, pengpeng, yaojiale02, suunj1331,
ali, tim.bird, linux-bluetooth, linux-kernel, pav
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Sat, 22 Aug 2026 23:06:19 +0800 you wrote:
> rfcomm_kill_listener() walks session_list and deletes every session
> without holding rfcomm_mutex, unlike the normal session processing and
> connect error paths.
>
> Under normal operation, an open RFCOMM socket pins rfcomm.ko, so
> rfcomm_kill_listener() does not run concurrently with rfcomm_dlc_open().
> However, forced module unload via delete_module(O_TRUNC) can stop
> krfcommd while a failed connect is still unwinding.
>
> [...]
Here is the summary with links:
- [v2] Bluetooth: RFCOMM: serialize session teardown
https://git.kernel.org/bluetooth/bluetooth-next/c/fe3897b4ab57
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-08-24 16:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-22 15:06 [PATCH v2] Bluetooth: RFCOMM: serialize session teardown Chengfeng Ye
2026-08-22 15:44 ` [v2] " bluez.test.bot
2026-08-24 16:50 ` [PATCH v2] " 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