]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: ISO: Fix possible UAF on iso_conn_free
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 22 Sep 2025 20:27:51 +0000 (16:27 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sat, 27 Sep 2025 15:37:43 +0000 (11:37 -0400)
This attempt to fix similar issue to sco_conn_free where if the
conn->sk is not set to NULL may lead to UAF on iso_conn_free.

Fixes: ccf74f2390d6 ("Bluetooth: Add BTPROTO_ISO socket type")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/iso.c

index 5c68c0ea7d97493dee366c716e30e6ce70fe1d2e..d24c7a1ace92bba2ff1374e319a320aa06bb9378 100644 (file)
@@ -761,6 +761,13 @@ static void iso_sock_kill(struct sock *sk)
 
        BT_DBG("sk %p state %d", sk, sk->sk_state);
 
+       /* Sock is dead, so set conn->sk to NULL to avoid possible UAF */
+       if (iso_pi(sk)->conn) {
+               iso_conn_lock(iso_pi(sk)->conn);
+               iso_pi(sk)->conn->sk = NULL;
+               iso_conn_unlock(iso_pi(sk)->conn);
+       }
+
        /* Kill poor orphan */
        bt_sock_unlink(&iso_sk_list, sk);
        sock_set_flag(sk, SOCK_DEAD);