All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_core: Fix slab-use-after-free in hci_cmd_work
@ 2025-12-24 23:54 Szymon Wilczek
  2025-12-25  1:33 ` bluez.test.bot
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Szymon Wilczek @ 2025-12-24 23:54 UTC (permalink / raw)
  To: Marcel Holtmann, Johan Hedberg, Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, syzbot+4d6b203d625d2f57d4ca,
	Szymon Wilczek

syzbot reported a slab-use-after-free in hci_cmd_work.
The issue is that hci_send_cmd_sync() consumes the skb reference
(either by passing it to the driver which frees it, or by calling
kfree_skb() on error), but the skb might be accessed after the call
in certain configurations or due to race conditions with the freeing
process (e.g. vhci_read).

Explicitly hold a reference to the skb using skb_get() before calling
hci_send_cmd_sync() and release it with kfree_skb() afterwards. This
ensures the skb object remains valid throughout the function call,
regardless of how hci_send_cmd_sync() handles the original reference.

Reported-by: syzbot+4d6b203d625d2f57d4ca@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4d6b203d625d2f57d4ca
Signed-off-by: Szymon Wilczek <swilczek.lx@gmail.com>
---
 net/bluetooth/hci_core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8ccec73dce45..af4ef31295c4 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -4149,7 +4149,10 @@ static void hci_cmd_work(struct work_struct *work)
 		if (!skb)
 			return;
 
+		skb_get(skb);
 		err = hci_send_cmd_sync(hdev, skb);
+		kfree_skb(skb);
+
 		if (err)
 			return;
 
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-12-25 22:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-24 23:54 [PATCH] Bluetooth: hci_core: Fix slab-use-after-free in hci_cmd_work Szymon Wilczek
2025-12-25  1:33 ` bluez.test.bot
2025-12-25  2:09 ` [PATCH] " Hillf Danton
2025-12-25  9:19 ` [PATCH v2] Bluetooth: vhci: Fix slab-use-after-free by cloning skb Szymon Wilczek
2025-12-25 10:04   ` [v2] " bluez.test.bot
2025-12-25 10:12 ` [PATCH v3] " Szymon Wilczek
2025-12-25 22:39 ` [PATCH] Bluetooth: hci_core: Fix slab-use-after-free in hci_cmd_work Pauli Virtanen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.