Skip to content

Commit f56960e

Browse files
author
Herton R. Krzesinski
committed
Merge: Bluetooth: L2CAP: Fix memory leak in vhci_write
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1958 Bugzilla: https://bugzilla.redhat.com/2155874 CVE: CVE-2022-3619 commit 7c9524d Author: Hawkins Jiawei <yin31149@gmail.com> Date: Tue Oct 18 10:18:51 2022 +0800 Bluetooth: L2CAP: Fix memory leak in vhci_write Syzkaller reports a memory leak as follows: ==================================== BUG: memory leak unreferenced object 0xffff88810d81ac00 (size 240): [...] hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<ffffffff838733d9>] __alloc_skb+0x1f9/0x270 net/core/skbuff.c:418 [<ffffffff833f742f>] alloc_skb include/linux/skbuff.h:1257 [inline] [<ffffffff833f742f>] bt_skb_alloc include/net/bluetooth/bluetooth.h:469 [inline] [<ffffffff833f742f>] vhci_get_user drivers/bluetooth/hci_vhci.c:391 [inline] [<ffffffff833f742f>] vhci_write+0x5f/0x230 drivers/bluetooth/hci_vhci.c:511 [<ffffffff815e398d>] call_write_iter include/linux/fs.h:2192 [inline] [<ffffffff815e398d>] new_sync_write fs/read_write.c:491 [inline] [<ffffffff815e398d>] vfs_write+0x42d/0x540 fs/read_write.c:578 [<ffffffff815e3cdd>] ksys_write+0x9d/0x160 fs/read_write.c:631 [<ffffffff845e0645>] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [<ffffffff845e0645>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 [<ffffffff84600087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd ==================================== HCI core will uses hci_rx_work() to process frame, which is queued to the hdev->rx_q tail in hci_recv_frame() by HCI driver. Yet the problem is that, HCI core may not free the skb after handling ACL data packets. To be more specific, when start fragment does not contain the L2CAP length, HCI core just copies skb into conn->rx_skb and finishes frame process in l2cap_recv_acldata(), without freeing the skb, which triggers the above memory leak. This patch solves it by releasing the relative skb, after processing the above case in l2cap_recv_acldata(). Fixes: 4d7ea8e ("Bluetooth: L2CAP: Fix handling fragmented length") Link: https://lore.kernel.org/all/0000000000000d0b1905e6aaef64@google.com/ Reported-and-tested-by: syzbot+8f819e36e01022991cfa@syzkaller.appspotmail.com Signed-off-by: Hawkins Jiawei <yin31149@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Wander Lairson Costa <wander@redhat.com> Approved-by: Julia Denham <jdenham@redhat.com> Approved-by: Ricardo Robaina <rrobaina@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 622e3a7 + 8e4a6eb commit f56960e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8443,9 +8443,8 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
84438443
* expected length.
84448444
*/
84458445
if (skb->len < L2CAP_LEN_SIZE) {
8446-
if (l2cap_recv_frag(conn, skb, conn->mtu) < 0)
8447-
goto drop;
8448-
return;
8446+
l2cap_recv_frag(conn, skb, conn->mtu);
8447+
break;
84498448
}
84508449

84518450
len = get_unaligned_le16(skb->data) + L2CAP_HDR_SIZE;
@@ -8489,7 +8488,7 @@ void l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags)
84898488

84908489
/* Header still could not be read just continue */
84918490
if (conn->rx_skb->len < L2CAP_LEN_SIZE)
8492-
return;
8491+
break;
84938492
}
84948493

84958494
if (skb->len > conn->rx_len) {

0 commit comments

Comments
 (0)