* [PATCH] Bluetooth: virtio_bt: fix skb double-free when send fails
@ 2026-11-27 7:08 17868388227
2026-11-27 13:55 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: 17868388227 @ 2026-11-27 7:08 UTC (permalink / raw)
To: marcel, luiz.dentz, linux-bluetooth; +Cc: linux-kernel, stable
From: Mingshu Liu <26031212613@stu.xidian.edu.cn>
A double-free of struct sk_buff and a subsequent use-after-free were
observed in virtbt_send_frame() when virtqueue_add_outbuf() fails.
hci_send_frame() frees the same skb again after hdev->send() returns
an error.
This issue was triggered by our custom device emulation and fuzzing
framework on Linux 7.3 (7.3.0-00001-g0aef6eb5c859-dirty).
The extra local commit only adds kcov and does not touch virtio_bt.c.
The same error path is still present on mainline. The failure depends
on a broken TX virtqueue: the device first completes a buffer whose
used-ring id is not a head, the queue is marked broken, and the next
virtqueue_add_outbuf() returns -EIO.
The crash trace is as follows:
virtio_bt virtio0: tx:id 3 is not a head!
Bluetooth: hci0: sending frame failed (-5)
BUG: KASAN: slab-use-after-free in sk_skb_reason_drop+0x3c/0x1b0
Read of size 4 at addr ffff88800ae5bee4 by task kworker/u17:0/71
Workqueue: hci0 hci_tx_work
Call Trace:
<TASK>
sk_skb_reason_drop+0x3c/0x1b0
hci_send_frame+0x34a/0x420
hci_tx_work+0x87a/0xcd0
process_one_work+0x8cd/0x1900
worker_thread+0x5a1/0xd10
kthread+0x325/0x410
ret_from_fork+0x566/0x7f0
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 50:
__alloc_skb+0x14c/0x6e0
l2cap_send_cmd+0x96/0xbf0
l2cap_conn_start+0x33c/0x9e0
l2cap_info_timeout+0x82/0xa0
Freed by task 71:
kfree_skbmem+0x18a/0x1f0
sk_skb_reason_drop+0x10e/0x1b0
virtbt_send_frame+0x1bc/0x210
hci_send_frame+0x26a/0x420
hci_tx_work+0x87a/0xcd0
The object belongs to skbuff_head_cache and is 240 bytes. The 4-byte
read is skb->users.
The issue arises because virtbt_send_frame() calls kfree_skb(skb) when
virtqueue_add_outbuf() fails and still returns that error.
hci_send_frame() treats a negative return as "the caller still owns
the skb" and frees it a second time. Both calls run in the same
hci_tx_work. The skb was never queued to the device.
Fix this by leaving the skb to hci_send_frame() on the error path.
Undo the preceding skb_push() so the buffer handed back matches the
one the caller passed in.
Fixes: afd2daa26c7a ("Bluetooth: Add support for virtio transport driver")
Cc: stable@vger.kernel.org
Signed-off-by: Mingshu Liu <26031212613@stu.xidian.edu.cn>
---
drivers/bluetooth/virtio_bt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index c20d54088..c6bb602b4 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -103,7 +103,7 @@ static int virtbt_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
err = virtqueue_add_outbuf(vbt->vqs[VIRTBT_VQ_TX], sg, 1, skb,
GFP_KERNEL);
if (err) {
- kfree_skb(skb);
+ skb_pull(skb, 1);
return err;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: Bluetooth: virtio_bt: fix skb double-free when send fails
2026-11-27 7:08 [PATCH] Bluetooth: virtio_bt: fix skb double-free when send fails 17868388227
@ 2026-11-27 13:55 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-27 13:55 UTC (permalink / raw)
To: linux-bluetooth, 17868388227
[-- Attachment #1: Type: text/plain, Size: 2880 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/1224050/
---Test result---
Test Summary:
CheckPatch PASS 0.54 seconds
VerifyFixes PASS 0.08 seconds
VerifySignedoff PASS 0.08 seconds
GitLint PASS 0.23 seconds
SubjectPrefix PASS 0.07 seconds
BuildKernel PASS 25.28 seconds
CheckAllWarning PASS 28.82 seconds
CheckSparse WARNING 30.72 seconds
BuildKernel32 PASS 25.22 seconds
CheckKernelLLVM PASS 25.62 seconds
TestRunnerSetup PASS 567.39 seconds
IncrementalBuild PASS 22.46 seconds
Details
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
drivers/bluetooth/virtio_bt.c:340:25: error: no generic selection for 'unsigned short virtio_cread_v'drivers/bluetooth/virtio_bt.c:340:25: error: incompatible types in comparison expression (different base types):drivers/bluetooth/virtio_bt.c:340:25: bad type *drivers/bluetooth/virtio_bt.c:340:25: unsigned short *drivers/bluetooth/virtio_bt.c:340:25: error: no generic selection for 'unsigned short [addressable] virtio_cread_v'drivers/bluetooth/virtio_bt.c:343:25: error: no generic selection for 'unsigned short virtio_cread_v'drivers/bluetooth/virtio_bt.c:343:25: error: incompatible types in comparison expression (different base types):drivers/bluetooth/virtio_bt.c:343:25: bad type *drivers/bluetooth/virtio_bt.c:343:25: unsigned short *drivers/bluetooth/virtio_bt.c:343:25: error: no generic selection for 'unsigned short [addressable] virtio_cread_v'drivers/bluetooth/virtio_bt.c:378:25: error: no generic selection for 'unsigned short virtio_cread_v'drivers/bluetooth/virtio_bt.c:378:25: error: incompatible types in comparison expression (different base types):drivers/bluetooth/virtio_bt.c:378:25: bad type *drivers/bluetooth/virtio_bt.c:378:25: unsigned short *drivers/bluetooth/virtio_bt.c:378:25: error: no generic selection for 'unsigned short [addressable] virtio_cread_v'drivers/bluetooth/virtio_bt.c:381:25: error: no generic selection for 'unsigned short virtio_cread_v'drivers/bluetooth/virtio_bt.c:381:25: error: incompatible types in comparison expression (different base types):drivers/bluetooth/virtio_bt.c:381:25: bad type *drivers/bluetooth/virtio_bt.c:381:25: unsigned short *drivers/bluetooth/virtio_bt.c:381:25: error: no generic selection for 'unsigned short [addressable] virtio_cread_v'
https://github.com/bluez/bluetooth-next/pull/1240
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 7:08 [PATCH] Bluetooth: virtio_bt: fix skb double-free when send fails 17868388227
2026-11-27 13:55 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox