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 E2AF2238D27 for ; Sat, 9 May 2026 02:04:29 +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=1778292270; cv=none; b=CX5CEv7qqcZj5XZuJlJkMe2BrOh99ULEWrFE8mlDKJzBxUSwYRjJBa6keXcr01M1yuq3sELHC6k6HRbOobn7s34cZJhYoJOhKOzduAxDxXdW/WmrXGAGXxVPsdjCZ1I3I74eK1eqzwhVNccnSIf6P2woom9oMqosJn2tXSngoHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778292270; c=relaxed/simple; bh=VuCVlp7woncgTF/NPjBkIyeZKuoIgDJltpL9z6uTkFA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CKMlcluzceV/qYPKajgBIE/maIbSZJ6BkmlKdnl9G981LA6H04aLk+Q2GMr8ejfJ+Khxvb6tQpp3PYQSHT3CsIKJykPSz4IFtyTUXmfi/FkDW3+p32f8QWuA+zdIrWPrc/EYlik5baS1Lt9YYEgn2ChtQwZMalzA74FGNWuc5Cs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IwkjNXa6; 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="IwkjNXa6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E8AFC2BCC9; Sat, 9 May 2026 02:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778292269; bh=VuCVlp7woncgTF/NPjBkIyeZKuoIgDJltpL9z6uTkFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IwkjNXa6PsV0pMeJCUom2ZUHmwfGAL0A4fFsFGv1IxrNt+i5rRCR1n/W5S+91LvqA zjRWfRRSRXR97ejqiy41LQvuqJXYszJisFxmJU7H5bI5KgJHEAdgtw9UEFYhEjsXSO LviCFo+Qhqb2lO0x0p5fI7RiRF7jsNeeVLD6wORaCzmHDZZixREGOuIIaAsQhrvZDF pQxMptS+x5Insi3InwbkHY2mYtpZZoNSc5lGHm0pkg0Kly5AcQhtH7l2cpRcvcFIvM TBnAAV2KQ2tR5A6m0HEkqOb46RibgkGJDzT/l6eFFhICAn96v4k0bSBcj+bneFWc23 AKmKkXoQfNO5Q== From: Sasha Levin To: stable@vger.kernel.org Cc: Shuvam Pandey , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.10.y] Bluetooth: hci_event: fix potential UAF in SSP passkey handlers Date: Fri, 8 May 2026 22:04:26 -0400 Message-ID: <20260509020426.2866832-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026050441-triage-enviably-1b47@gregkh> References: <2026050441-triage-enviably-1b47@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 6310f4f9890eb..e0436f5906fc9 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -4845,9 +4845,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; @@ -4856,6 +4858,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) @@ -4865,14 +4870,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++; @@ -4887,13 +4894,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