From nobody Mon Jun 15 09:44:53 2026 Received: from smtp134-32.sina.com.cn (smtp134-32.sina.com.cn [180.149.134.32]) (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 504AD37F735 for ; Thu, 9 Apr 2026 07:44:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=180.149.134.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775720680; cv=none; b=NHgYlTO+ZbS3jKKw+Vp3ZDvhElzjKLT+1xUU11TOEX5s4tLJc9vOHzDK5mr/EAIYk+zKp5q+KRbtauH85d6pUE9/Z5tkDueiMDHvUWugjVlzqRR7DuATydFKTXhNwO4cc2mDjA6ZLJbbcG+Uj6fYCQEW81IsniD7mHXgme8cFuU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775720680; c=relaxed/simple; bh=f0DDryUDANCVJdeh2y1ARDxV4C4xuBi4Rc6Sb9agruM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=s6j3JyaJVYUNhGtahLpZtGzVypFMhnrm6beqXmS46OKLcgmIi2Vljfdzbr2xeisinX01KOpkkTOAxZ/ctiKEOMmfGVt7iBrGspjBMfNwbRuc3jb8z/apwOuxew9r37slNy/FEIEChxm1LpfUZu91R519NSVFuMBnGABDbsZdQt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.cn; spf=pass smtp.mailfrom=sina.cn; dkim=pass (1024-bit key) header.d=sina.cn header.i=@sina.cn header.b=YlI2hWtd; arc=none smtp.client-ip=180.149.134.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.cn header.i=@sina.cn header.b="YlI2hWtd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.cn; s=201208; t=1775720675; bh=N6N2PGq6dFDonMyCZBS+lQxmTRjyaDG+D6z3I54ANUk=; h=From:Subject:Date:Message-Id; b=YlI2hWtd8YeXK5ZtwQkT651OmP3h7YW+TFckYV32g4zKVFT+dUqqp7DIgO4yI0CAt 2wk6zqy62RxWhpcT6jk+U8tPUg/jtTtU+cXcuxXhcnUbY5eCSgRNfu3+e04g0Jl4Ok ZS4AnQ/dVNEmaglFPcnFfaMCjVk/7zbt/+Z5uz9g= X-SMAIL-HELO: NTT-kernel-dev Received: from unknown (HELO NTT-kernel-dev)([60.247.85.88]) by sina.cn (10.185.250.21) with ESMTP id 69D758DD00006C49; Thu, 9 Apr 2026 15:44:31 +0800 (CST) X-Sender: jianqkang@sina.cn X-Auth-ID: jianqkang@sina.cn Authentication-Results: sina.cn; spf=none smtp.mailfrom=jianqkang@sina.cn; dkim=none header.i=none; dmarc=none action=none header.from=jianqkang@sina.cn X-SMAIL-MID: 6999273408359 X-SMAIL-UIID: 7E8DE10F63EF47689E1EDF482DBA0A2B-20260409-154431-1 From: Jianqiang kang To: gregkh@linuxfoundation.org, stable@vger.kernel.org, imv4bel@gmail.com Cc: patches@lists.linux.dev, linux-kernel@vger.kernel.org, marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com, davem@davemloft.net, kuba@kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, luiz.von.dentz@intel.com Subject: [PATCH 5.10.y] Bluetooth: SCO: Fix use-after-free in sco_recv_frame() due to missing sock_hold Date: Thu, 9 Apr 2026 15:44:29 +0800 Message-Id: <20260409074429.740279-1-jianqkang@sina.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: Jianqiang kang --- 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 ce084a184a1c..c441e5225458 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c @@ -305,7 +305,7 @@ static void sco_recv_frame(struct sco_conn *conn, struc= t sk_buff *skb) struct sock *sk; =20 sco_conn_lock(conn); - sk =3D conn->sk; + sk =3D sco_sock_hold(conn); sco_conn_unlock(conn); =20 if (!sk) @@ -314,11 +314,15 @@ static void sco_recv_frame(struct sco_conn *conn, str= uct sk_buff *skb) BT_DBG("sk %p len %d", sk, skb->len); =20 if (sk->sk_state !=3D BT_CONNECTED) - goto drop; + goto drop_put; =20 - if (!sock_queue_rcv_skb(sk, skb)) + if (!sock_queue_rcv_skb(sk, skb)) { + sock_put(sk); return; + } =20 +drop_put: + sock_put(sk); drop: kfree_skb(skb); } --=20 2.34.1