]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: ISO: Fix a use-after-free of the hci_conn pointer
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 1 Jun 2026 18:52:09 +0000 (14:52 -0400)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 3 Jun 2026 15:23:09 +0000 (11:23 -0400)
In iso_sock_rebind_bc(), the bis pointer is cached, then the socket lock is
dropped:
bis = iso_pi(sk)->conn->hcon;
/* Release the socket before lookups since that requires hci_dev_lock
 * which shall not be acquired while holding sock_lock for proper
 * ordering.
 */
release_sock(sk);
hci_dev_lock(bis->hdev);

During the unlocked window, could a concurrent close() destroy the connection
and free the bis structure, causing hci_dev_lock(bis->hdev) to access memory
after it is freed, fix this by using the hdev reference which was safely
acquired via iso_conn_get_hdev().

Fixes: d3413703d5f8 ("Bluetooth: ISO: Add support to bind to trigger PAST")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/iso.c

index 3d707c43bdc09b19d3225ac36a479c650bb3e1ea..c21ed2bb3cf8f9b9d77aedcaa9a2b153475846c5 100644 (file)
@@ -1082,7 +1082,7 @@ static int iso_sock_rebind_bc(struct sock *sk, struct sockaddr_iso *sa,
         * ordering.
         */
        release_sock(sk);
-       hci_dev_lock(bis->hdev);
+       hci_dev_lock(hdev);
        lock_sock(sk);
 
        if (!iso_pi(sk)->conn || iso_pi(sk)->conn->hcon != bis) {