From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B2E4C233722; Mon, 13 Apr 2026 16:31:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097906; cv=none; b=qXX7znodSVb2SoCtO91OhnDBIYBrWkqZvOEMp8B8TyLcKD0YX04PeBWhb9O0WXDxQKl2Iyi5x6elQpD4KD7xEWt4w/TBPWG/CJdCkgsZqH8kvm4oGFulbH8EBmSX/tAQAkFGIp5aAB/8Ff/KR/F5VxzqbUQvLZFSd3uwc2UCbq8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097906; c=relaxed/simple; bh=T8wDBAbdP6EBTjHoeUByjD2Lw1WaH0yk1K0KdxH/v6w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DGEOE8sqbPeHAieDZxOkl7u3Qu32Ss59xr28kxx8GEz0+w23hJ1GohcDls31GxmBKsdznTC+/1z7O34FIttDlV02BqXLXWjgNkrwKv571V2FzsVCHmt1/yP7I7yFri1eA/B5PuW2au9oqoC9hMl1P8XtIUvSI+UpdGSADh6hIPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=A4aqtvyM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="A4aqtvyM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48EE4C2BCAF; Mon, 13 Apr 2026 16:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776097906; bh=T8wDBAbdP6EBTjHoeUByjD2Lw1WaH0yk1K0KdxH/v6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4aqtvyMvVrtOQJg8hhhXP20GmoJO6MeB6f5Kd5Uj/9H1IIi15b/mS2fK+2MxyF9B cOGGkJgyGOnGgUqAflCCfVaDP9vFpZ+17rHhodx0s5CaWt+2VJ6s/6POr69+3MfKMi zllMDLjzfHNIT0fZs4IEP2qd5+XpMMgt0fzzswmo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hyunwoo Kim , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.15 318/570] Bluetooth: SCO: Fix use-after-free in sco_recv_frame() due to missing sock_hold Date: Mon, 13 Apr 2026 17:57:29 +0200 Message-ID: <20260413155842.408234920@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hyunwoo Kim [ Upstream commit 598dbba9919c5e36c54fe1709b557d64120cb94b ] sco_recv_frame() reads conn->sk under sco_conn_lock() but immediately releases the lock without holding a reference to the socket. A concurrent close() can free the socket between the lock release and the subsequent sk->sk_state access, resulting in a use-after-free. Other functions in the same file (sco_sock_timeout(), sco_conn_del()) correctly use sco_sock_hold() to safely hold a reference under the lock. Fix by using sco_sock_hold() to take a reference before releasing the lock, and adding sock_put() on all exit paths. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Hyunwoo Kim Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/sco.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index d98648bcc1a85..d0ef74c45914c 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -311,7 +311,7 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) struct sock *sk; sco_conn_lock(conn); - sk = conn->sk; + sk = sco_sock_hold(conn); sco_conn_unlock(conn); if (!sk) @@ -320,11 +320,15 @@ static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb) BT_DBG("sk %p len %u", sk, skb->len); if (sk->sk_state != BT_CONNECTED) - goto drop; + goto drop_put; - if (!sock_queue_rcv_skb(sk, skb)) + if (!sock_queue_rcv_skb(sk, skb)) { + sock_put(sk); return; + } +drop_put: + sock_put(sk); drop: kfree_skb(skb); } -- 2.51.0