From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 688F625B0B4; Thu, 16 Jul 2026 13:45:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784209509; cv=none; b=UPXAMPaLuGkSM40MfXvAGcoasWiTBhwC+EoXAORp/nUE8gAIlG87GDITeeVFRJuOB6msN/b1Yzu/PqT8z8gm81tETDzQm5Hc+B4qssVQPv+uTB5CX1iB6inPgqUH6c30xa773Nkv1WemZDR2Ig+uOgV8B0Ri4TxJ7OCMIhrS7hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784209509; c=relaxed/simple; bh=oz4Wkzjjp4b82invI/kLx9EpnxuLOYbix1tdJ/OEI04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vu8yR8bg1NlmeFYA2+mfYHe/MSD2KD4JlxO2w44pS5E5KDyQTRV4bCiI4lxLud5aPG+rZOoV8aqS1wfAoyWpHUr0Aa6Jsm8bpCEehegY+nfhMqmInqAD8Ot3qxQnjfdHDv9CrK2NjKBxC3eUpv1gsaIltZo4ccJP2O1pEFt2Ges= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zt+bP4vQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zt+bP4vQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84C7E1F000E9; Thu, 16 Jul 2026 13:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784209508; bh=FdmErbzqvAXywxEFGZXuOGVa68BXNTbPIFUTEXGBKUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zt+bP4vQv+m49ZYCUFkof5w+0MvhCyMTqouIlcPzpGcZ8ZiQzLWajefKB1BpPhoWc QW3GWnzdRbOfVxde6VtTD7qjXeKd3CoHGhC9u+yAyG9AcLSLb2ETTNf9SECGP/9Tn/ ncOekmho1mS/pUV3YfOwzVLhIl/8Q2/j0zMVYAXQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Muhammad Bilal , Luiz Augusto von Dentz Subject: [PATCH 7.1 210/518] Bluetooth: ISO: avoid NULL deref of conn in iso_conn_big_sync() Date: Thu, 16 Jul 2026 15:27:58 +0200 Message-ID: <20260716133052.413240440@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260716133047.772246337@linuxfoundation.org> References: <20260716133047.772246337@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Muhammad Bilal commit d5541eb148da72d5e0a1bca8ecd171f9fc8b366f upstream. iso_conn_big_sync() drops the socket lock to call hci_get_route() and then re-acquires it, but dereferences iso_pi(sk)->conn->hcon afterwards without re-checking that conn is still valid. While the lock is dropped, the connection can be torn down under the same socket lock: iso_disconn_cfm() -> iso_conn_del() -> iso_chan_del() sets iso_pi(sk)->conn to NULL (and the broadcast teardown path can also clear conn->hcon on its own). When iso_conn_big_sync() re-acquires the lock and reads conn->hcon, conn may be NULL, causing a NULL pointer dereference (hcon is the first member of struct iso_conn). This path is reached from iso_sock_recvmsg() for a PA-sync broadcast sink socket (BT_SK_DEFER_SETUP | BT_SK_PA_SYNC), so the dropped-lock window can race with connection teardown driven by controller events. Re-validate iso_pi(sk)->conn and its hcon after re-acquiring the socket lock and bail out if the connection went away, as already done in the sibling iso_sock_rebind_bc(). Fixes: 7a17308c17880d ("Bluetooth: iso: Fix circular lock in iso_conn_big_sync") Cc: stable@vger.kernel.org Signed-off-by: Muhammad Bilal Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/iso.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1589,6 +1589,7 @@ static void iso_conn_big_sync(struct soc { int err; struct hci_dev *hdev; + struct iso_conn *conn; bdaddr_t src, dst; u8 src_type; @@ -1611,8 +1612,17 @@ static void iso_conn_big_sync(struct soc hci_dev_lock(hdev); lock_sock(sk); + /* The socket lock was dropped for hci_get_route(), so the connection + * may have been torn down meanwhile: iso_chan_del() clears conn and + * the broadcast teardown path can clear conn->hcon on its own. Check + * both before dereferencing conn->hcon. + */ + conn = iso_pi(sk)->conn; + if (!conn || !conn->hcon) + goto unlock; + if (!test_and_set_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags)) { - err = hci_conn_big_create_sync(hdev, iso_pi(sk)->conn->hcon, + err = hci_conn_big_create_sync(hdev, conn->hcon, &iso_pi(sk)->qos, iso_pi(sk)->sync_handle, iso_pi(sk)->bc_num_bis, @@ -1621,6 +1631,7 @@ static void iso_conn_big_sync(struct soc bt_dev_err(hdev, "hci_big_create_sync: %d", err); } +unlock: release_sock(sk); hci_dev_unlock(hdev); hci_dev_put(hdev);