From nobody Mon Apr 6 19:59:51 2026 Received: from mail115-95.sinamail.sina.com.cn (mail115-95.sinamail.sina.com.cn [218.30.115.95]) (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 E87D6354AE2 for ; Wed, 18 Mar 2026 04:40:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.95 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773808837; cv=none; b=iAcAtSEjODAbzFL9gWMqBB1D63+87pTXUFTxZE1tEYREcHZuNKZf0yhG16iM1wYoRwYziwI3pOqorHB6goPOw5Sqpfx/hiCUscP1wC3lpM3uvlVuyMTT3Ccm4b9jC5f8DjziOtX2+DEyZVaEpnkKRj0w7V5Wpa77oTfMKaAZ8B4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773808837; c=relaxed/simple; bh=wkuOtXwODDY3jcLy6VCJdMGZYdtf25w2p+eNLa0cKjo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Dl8HdYaguTjVp1yyMoKzjDKuX7Vxw+YK4Hph1YOXj/aVFqFhgwr2jYfHyh/rE/ptYuXoH05YHvU/tCl2FmQYIn3CrqEwK0qLyzUq4tMwGSGjyca6wgocdq33FmuoAiYh4M2HO1wLZl+1qgQcUVXNtaAlX1urYoyTR0isDUsab+o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=V/1mEUbn; arc=none smtp.client-ip=218.30.115.95 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="V/1mEUbn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1773808833; bh=+qpPRUOZRmmOAJliwXda3/wgul6d4/w/Igh+o4wivXI=; h=From:Subject:Date:Message-Id; b=V/1mEUbni5H2U/Y/H4wW9PaLB0QHlhGWezc5NAmxinLJExyMB60wmXkHuXhby1/jG Ce0EjQgDpCBYooCGQtavCFJywHKNPfmKtzTEcyK/8txEGGfgc40pSW/cKmpfLgrdbp wqGmn7UEQ6y6RAZX0TePJumNcYohS1+iRk/ugh/g= X-SMAIL-HELO: pek-lpg-core6.wrs.com Received: from unknown (HELO pek-lpg-core6.wrs.com)([60.247.85.88]) by sina.com (10.185.250.23) with ESMTP id 69BA2CAE0000519C; Wed, 18 Mar 2026 12:40:19 +0800 (CST) X-Sender: johnny_haocn@sina.com X-Auth-ID: johnny_haocn@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=johnny_haocn@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=johnny_haocn@sina.com X-SMAIL-MID: 8534738912935 X-SMAIL-UIID: BD045F9390A54D469BFB2F37FC8FF18D-20260318-124019-1 From: Johnny Hao To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Luiz Augusto von Dentz , Johnny Hao Subject: [PATCH 5.15.y] Bluetooth: af_bluetooth: Fix deadlock Date: Wed, 18 Mar 2026 12:40:10 +0800 Message-Id: <20260318044010.3507623-1-johnny_haocn@sina.com> 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: Luiz Augusto von Dentz [ Upstream commit f7b94bdc1ec107c92262716b073b3e816d4784fb ] Attemting to do sock_lock on .recvmsg may cause a deadlock as shown bellow, so instead of using sock_sock this uses sk_receive_queue.lock on bt_sock_ioctl to avoid the UAF: INFO: task kworker/u9:1:121 blocked for more than 30 seconds. Not tainted 6.7.6-lemon #183 Workqueue: hci0 hci_rx_work Call Trace: __schedule+0x37d/0xa00 schedule+0x32/0xe0 __lock_sock+0x68/0xa0 ? __pfx_autoremove_wake_function+0x10/0x10 lock_sock_nested+0x43/0x50 l2cap_sock_recv_cb+0x21/0xa0 l2cap_recv_frame+0x55b/0x30a0 ? psi_task_switch+0xeb/0x270 ? finish_task_switch.isra.0+0x93/0x2a0 hci_rx_work+0x33a/0x3f0 process_one_work+0x13a/0x2f0 worker_thread+0x2f0/0x410 ? __pfx_worker_thread+0x10/0x10 kthread+0xe0/0x110 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x2c/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 Fixes: 2e07e8348ea4 ("Bluetooth: af_bluetooth: Fix Use-After-Free in bt_soc= k_recvmsg") Signed-off-by: Luiz Augusto von Dentz [ The context change is due to the commit f4b41f062c42 ("net: remove noblock parameter from skb_recv_datagram()") in v5.19 which is irrelevant to the logic of this patch. ] Signed-off-by: Johnny Hao --- net/bluetooth/af_bluetooth.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index aebef5cf12d4..2a55738000ae 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -285,14 +285,11 @@ int bt_sock_recvmsg(struct socket *sock, struct msghd= r *msg, size_t len, if (flags & MSG_OOB) return -EOPNOTSUPP; =20 - lock_sock(sk); - skb =3D skb_recv_datagram(sk, flags, noblock, &err); if (!skb) { if (sk->sk_shutdown & RCV_SHUTDOWN) err =3D 0; =20 - release_sock(sk); return err; } =20 @@ -318,8 +315,6 @@ int bt_sock_recvmsg(struct socket *sock, struct msghdr = *msg, size_t len, =20 skb_free_datagram(sk, skb); =20 - release_sock(sk); - if (flags & MSG_TRUNC) copied =3D skblen; =20 @@ -542,10 +537,11 @@ int bt_sock_ioctl(struct socket *sock, unsigned int c= md, unsigned long arg) if (sk->sk_state =3D=3D BT_LISTEN) return -EINVAL; =20 - lock_sock(sk); + spin_lock(&sk->sk_receive_queue.lock); skb =3D skb_peek(&sk->sk_receive_queue); amount =3D skb ? skb->len : 0; - release_sock(sk); + spin_unlock(&sk->sk_receive_queue.lock); + err =3D put_user(amount, (int __user *)arg); break; =20 --=20 2.34.1