From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+c12e2f941af1feb5632c@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_connect (2)
Date: Mon, 9 Sep 2024 19:06:41 +0800 [thread overview]
Message-ID: <20240909110641.2729-1-hdanton@sina.com> (raw)
In-Reply-To: <0000000000004a130a0621888811@google.com>
On Sat, 07 Sep 2024 07:42:26 -0700
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 788220eee30d Merge tag 'pm-6.11-rc7' of git://git.kernel.o..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1304189f980000
#syz test
--- x/net/bluetooth/l2cap_core.c
+++ y/net/bluetooth/l2cap_core.c
@@ -1792,13 +1792,10 @@ static void l2cap_conn_del(struct hci_co
mutex_unlock(&conn->chan_lock);
- hci_chan_del(conn->hchan);
-
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)
cancel_delayed_work_sync(&conn->info_timer);
hcon->l2cap_data = NULL;
- conn->hchan = NULL;
l2cap_conn_put(conn);
}
@@ -1806,6 +1803,7 @@ static void l2cap_conn_free(struct kref
{
struct l2cap_conn *conn = container_of(ref, struct l2cap_conn, ref);
+ hci_chan_del(conn->hchan);
hci_conn_put(conn->hcon);
kfree(conn);
}
@@ -7486,6 +7484,14 @@ void l2cap_recv_acldata(struct hci_conn
if (!conn)
goto drop;
+ hci_dev_lock(hcon->hdev);
+ if (conn != hcon->l2cap_data)
+ conn = NULL;
+ else
+ l2cap_conn_get(conn);
+ hci_dev_unlock(hcon->hdev);
+ if (!conn)
+ goto drop;
BT_DBG("conn %p len %u flags 0x%x", conn, skb->len, flags);
switch (flags) {
@@ -7512,6 +7518,7 @@ void l2cap_recv_acldata(struct hci_conn
if (len == skb->len) {
/* Complete frame received */
l2cap_recv_frame(conn, skb);
+ l2cap_conn_put(conn);
return;
}
@@ -7576,6 +7583,8 @@ void l2cap_recv_acldata(struct hci_conn
drop:
kfree_skb(skb);
+ if (conn)
+ l2cap_conn_put(conn);
}
static struct hci_cb l2cap_cb = {
--- x/net/bluetooth/hci_core.c
+++ y/net/bluetooth/hci_core.c
@@ -3782,6 +3782,8 @@ static void hci_acldata_packet(struct hc
hci_dev_lock(hdev);
conn = hci_conn_hash_lookup_handle(hdev, handle);
+ if (conn)
+ hci_conn_get(conn);
hci_dev_unlock(hdev);
if (conn) {
@@ -3789,6 +3791,7 @@ static void hci_acldata_packet(struct hc
/* Send to upper protocol */
l2cap_recv_acldata(conn, skb, flags);
+ hci_conn_put(conn);
return;
} else {
bt_dev_err(hdev, "ACL packet for unknown connection handle %d",
--
next prev parent reply other threads:[~2024-09-09 11:07 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-24 20:23 [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_connect (2) syzbot
2024-09-07 14:42 ` syzbot
2024-09-08 0:01 ` Hillf Danton
2024-09-08 0:24 ` syzbot
2024-09-08 1:28 ` Edward Adam Davis
2024-09-08 1:51 ` syzbot
2024-09-08 2:06 ` Edward Adam Davis
2024-09-08 2:29 ` syzbot
2024-09-08 2:41 ` Edward Adam Davis
2024-09-08 3:06 ` syzbot
2024-09-08 3:15 ` Edward Adam Davis
2024-09-08 3:58 ` syzbot
2024-09-08 3:25 ` Hillf Danton
2024-09-08 4:07 ` syzbot
2024-09-08 4:07 ` Edward Adam Davis
2024-09-08 4:37 ` syzbot
2024-09-08 7:22 ` [PATCH] Bluetooth/l2cap: Fix uaf in l2cap_connect Edward Adam Davis
2024-09-10 20:56 ` Luiz Augusto von Dentz
2024-09-20 15:07 ` Luiz Augusto von Dentz
2024-09-21 1:40 ` Edward Adam Davis
2024-09-21 10:56 ` Hillf Danton
2024-09-23 14:32 ` Luiz Augusto von Dentz
2024-09-23 14:37 ` Aleksandr Nogikh
2024-09-23 15:20 ` Luiz Augusto von Dentz
2024-09-23 15:28 ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_connect (2) syzbot
2024-09-23 15:38 ` [PATCH] Bluetooth/l2cap: Fix uaf in l2cap_connect Aleksandr Nogikh
2024-09-23 15:48 ` Luiz Augusto von Dentz
2024-09-23 16:21 ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_connect (2) syzbot
2024-09-08 8:32 ` Hillf Danton
2024-09-08 8:52 ` syzbot
2024-09-08 11:15 ` Hillf Danton
2024-09-08 11:33 ` syzbot
2024-09-08 12:50 ` Hillf Danton
2024-09-08 13:10 ` syzbot
2024-09-08 13:37 ` Hillf Danton
2024-09-08 13:58 ` syzbot
2024-09-09 11:06 ` Hillf Danton [this message]
2024-09-09 11:31 ` syzbot
2024-09-11 11:29 ` Hillf Danton
2024-09-11 11:59 ` syzbot
2024-09-12 11:49 ` Hillf Danton
2024-09-12 14:51 ` syzbot
2024-09-10 18:43 ` syzbot
2024-09-23 16:13 ` [syzbot] Re: [PATCH] Bluetooth/l2cap: Fix uaf in l2cap_connect syzbot
[not found] <CABBYNZ+Fj1bDqSG7PkF5OFEx_OWkgm2gEm8640odaQX5EBGxPg@mail.gmail.com>
2024-09-23 16:45 ` [syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_connect (2) syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240909110641.2729-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+c12e2f941af1feb5632c@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox