Re: [syzbot] test uaf in hci_conn_drop

From: syzbot
Date: Sat Nov 04 2023 - 00:47:39 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: test uaf in hci_conn_drop
Author: lizhi.xu@xxxxxxxxxxxxx

#syz test git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git 8de1e7afcc1c

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 9d5057cef30a..bb02f1ca8cd0 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1719,6 +1719,7 @@ struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,

hci_sco_setup(acl, 0x00);
}
+ hci_conn_get(sco);

return sco;
}
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index c736186aba26..5cba9cfff8ec 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -442,6 +442,7 @@ static void __sco_sock_close(struct sock *sk)
sco_sock_set_timer(sk, SCO_DISCONN_TIMEOUT);
sco_conn_lock(sco_pi(sk)->conn);
hci_conn_drop(sco_pi(sk)->conn->hcon);
+ hci_conn_put(sco_pi(sk)->conn->hcon);
sco_pi(sk)->conn->hcon = NULL;
sco_conn_unlock(sco_pi(sk)->conn);
} else