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 AB48E15B0EC for ; Sat, 9 May 2026 01:33:23 +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=1778290403; cv=none; b=Ei6eXHh+utonV4kK7FO2DbQmoHuajD8uOtOu63RF7bcKH2GmishOfxQCCClm4e61OTYZtKbUX9Ajww0TTKru6CDsWZT2elhWoIEjvYSrhGfWCCdFKFysfzqBUAmtIkE9ne64FPxA8KhplWSh0D465FRYKFvoeJLfz51Oz4I1aXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778290403; c=relaxed/simple; bh=yRD/25lJXhW9YcPCeAD2lZzX4xWsQmQeYqqcQW72LaE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u2Ow6yhzp4v6Ux4G4rN1n7USnnj/tT5xO4Pswk2cjPvkyeXjPby+Dkzv9btlfqBmIZ5VdxG2R+t5g8TEC8cZ2eyEIKU0uV6wG15v7kGYgtdA5F6Lopo3X0MOReZHcvZdMS/L16JW7HDkNr/+Iy6VoJx+fbnm+PgdL3vkFxCMRKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=e+sHVjXY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="e+sHVjXY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2DDBC2BCB0; Sat, 9 May 2026 01:33:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778290403; bh=yRD/25lJXhW9YcPCeAD2lZzX4xWsQmQeYqqcQW72LaE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+sHVjXY863l7v6V4L4BANUfeNqNiyalJzEbaJCBhtR6juLbEcfVfrqmiSzcVMz3x MvvnnKrnVhM65TEcDIxF0PEqRbIvLJl7xKKldWtuhQDbGroCzewX0wn7uTBrEJqR7W sOFTEWdz6u4mnNTunxvBjghImbIDQ/FqR85cr8Fda5U5k0p1GovWkq2RMwON5BY9sr w8ja99YWhpidHPbk9GsAes/PqVcJPnHSlle2l2Xsw45OhaKgfUUObhgl+jXPJf6lRr OlV7LjpXHlj67OLG+lLviP7kfcvKb9BzohWmQf8ydBJo5SiaCfLXYcnxcDljr5AN2g SJEIp2tyCeCNQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Shuvam Pandey , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.15.y] Bluetooth: hci_event: fix potential UAF in SSP passkey handlers Date: Fri, 8 May 2026 21:33:20 -0400 Message-ID: <20260509013320.2851098-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026050440-overlaid-handpick-7fc8@gregkh> References: <2026050440-overlaid-handpick-7fc8@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- net/bluetooth/hci_event.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 8d6fc3a0c9a7e..b176cac9e0334 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4956,9 +4956,11 @@ static void hci_user_passkey_notify_evt(struct hci_dev *hdev, 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; @@ -4967,6 +4969,9 @@ static void hci_user_passkey_notify_evt(struct hci_dev *hdev, 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) @@ -4976,14 +4981,16 @@ static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) 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++; @@ -4998,13 +5005,16 @@ static void hci_keypress_notify_evt(struct hci_dev *hdev, struct sk_buff *skb) 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, -- 2.53.0