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 5C33A43CEC7; Tue, 16 Jun 2026 18:29:20 +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=1781634561; cv=none; b=LSVm8JFc3r5hjSkLU1cb/oPITzaTB00DC4VGe7Um2gpryPN3x7QQ2ksVgGCcsVxCubAyfQGc1bBj81wcsV7SegbETv7onwVikWYox1wxUQZwK8FKCFWNoaCddbnCWBB7aqz/HJKAeuH4X0MIAyFV1VfQIH6PykRM16ePC774hH0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781634561; c=relaxed/simple; bh=nfg8nAKkJVGZxHLQXvHVlyCFGF+UPuIh1JdVkl6g+a8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T/B/qKiSgAyeCKuxrOiT5/fN3aR1TDy2PoJA2S5Lg2Bvxa8rvn+ZGZXpDRPZD6rM57xhbHDRwBwVMNQYA8Vl3vW2hm6cdap7FXCJovQaSfvjRy/5yVrMA8Ew6Fty1yStYLCCeoXAo6Miox1co57/qtz7JDRuBSYFIjdFOKrOqiU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oQS3VZWK; 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="oQS3VZWK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 632111F000E9; Tue, 16 Jun 2026 18:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781634560; bh=Vrig6OaOXRm55tn7RZ/OhfBVaB365n0Vh2i6qfD2qbo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oQS3VZWKb5v5b2bUO3AZHAzllCtrfO6xF5Fpn4k4nqleH/GY933q3Os4qWS7MOJrO pDstspEBw+2vve/bovJP/18pH1mH3C1GBHL6VlkyMiZ3Agkud+xgJGjuW+GMOV7Fyi ykSGyfwJHOb56WgK07otSySNu79zn6ATpQK3uSLA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shuvam Pandey , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.15 287/411] Bluetooth: hci_event: fix potential UAF in SSP passkey handlers Date: Tue, 16 Jun 2026 20:28:45 +0530 Message-ID: <20260616145116.411046361@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145100.376842714@linuxfoundation.org> References: <20260616145100.376842714@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: Shuvam Pandey [ Upstream commit 85fa3512048793076eef658f66489112dcc91993 ] hci_conn lookup and field access must be covered by hdev lock in hci_user_passkey_notify_evt() and hci_keypress_notify_evt(), otherwise the connection can be freed concurrently. Extend the hci_dev_lock critical section to cover all conn usage in both handlers. Keep the existing keypress notification behavior unchanged by routing the early exits through a common unlock path. Fixes: 92a25256f142 ("Bluetooth: mgmt: Implement support for passkey notification") Cc: stable@vger.kernel.org Signed-off-by: Shuvam Pandey Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/hci_event.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4953,9 +4953,11 @@ static void hci_user_passkey_notify_evt( BT_DBG("%s", hdev->name); + hci_dev_lock(hdev); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (!conn) - return; + goto unlock; conn->passkey_notify = __le32_to_cpu(ev->passkey); conn->passkey_entered = 0; @@ -4964,6 +4966,9 @@ static void hci_user_passkey_notify_evt( mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, conn->dst_type, conn->passkey_notify, conn->passkey_entered); + +unlock: + hci_dev_unlock(hdev); } static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) @@ -4973,14 +4978,16 @@ static void hci_keypress_notify_evt(stru BT_DBG("%s", hdev->name); + hci_dev_lock(hdev); + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); if (!conn) - return; + goto unlock; switch (ev->type) { case HCI_KEYPRESS_STARTED: conn->passkey_entered = 0; - return; + goto unlock; case HCI_KEYPRESS_ENTERED: conn->passkey_entered++; @@ -4995,13 +5002,16 @@ static void hci_keypress_notify_evt(stru break; case HCI_KEYPRESS_COMPLETED: - return; + goto unlock; } if (hci_dev_test_flag(hdev, HCI_MGMT)) mgmt_user_passkey_notify(hdev, &conn->dst, conn->type, conn->dst_type, conn->passkey_notify, conn->passkey_entered); + +unlock: + hci_dev_unlock(hdev); } static void hci_simple_pair_complete_evt(struct hci_dev *hdev,