]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: ISO: serialize iso_sock_clear_timer with socket lock
authorMuhammad Bilal <meatuni001@gmail.com>
Wed, 27 May 2026 04:59:18 +0000 (04:59 +0000)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 28 May 2026 12:52:21 +0000 (08:52 -0400)
iso_sock_close() calls iso_sock_clear_timer() before acquiring
lock_sock(sk).

iso_sock_clear_timer() reads iso_pi(sk)->conn twice without the
socket lock held:

    if (!iso_pi(sk)->conn)
        return;
    cancel_delayed_work(&iso_pi(sk)->conn->timeout_work);

Concurrently, iso_conn_del() executes under lock_sock(sk) and calls
iso_chan_del(), which sets iso_pi(sk)->conn to NULL and may result in
the final reference to the connection being dropped:

    CPU0                         CPU1
    ----                         ----
    iso_sock_clear_timer()
      if (conn != NULL) ...      lock_sock(sk)
                                   iso_chan_del()
                                   iso_pi(sk)->conn = NULL
      cancel_delayed_work(conn)  /* NULL deref or UAF */

iso_pi(sk)->conn is not stable across the unlock window, causing a
NULL pointer dereference or use-after-free.

Serialize iso_sock_clear_timer() with the socket lock by moving it
inside lock_sock()/release_sock(), matching the pattern used in
iso_conn_del() and all other call sites.

Fixes: ccf74f2390d60a2f9a75ef496d2564abb478f46a ("Bluetooth: Add BTPROTO_ISO socket type")
Cc: stable@vger.kernel.org
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/iso.c

index f03b7fa5dccc96ca194e7c9ece17341f3ea83529..876649556d3ccca0faaa7d9d2a995ea3c1337066 100644 (file)
@@ -864,8 +864,8 @@ static void __iso_sock_close(struct sock *sk)
 /* Must be called on unlocked socket. */
 static void iso_sock_close(struct sock *sk)
 {
-       iso_sock_clear_timer(sk);
        lock_sock(sk);
+       iso_sock_clear_timer(sk);
        __iso_sock_close(sk);
        release_sock(sk);
        iso_sock_kill(sk);