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 30F273F4124; Wed, 20 May 2026 17:25:27 +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=1779297929; cv=none; b=GQ5zoqrzXbbh7TMSc49mAX6o9WrV1A9RltmZymWP2hEywYq+KuizUdYOgEmowNZPGQ3b0mcUX6OWhq6mBvsP5pH5mBUpjxjHFkUHHmr3r608drK75kRl6xxaF2by38qy3CqHyIoYC874WRlkm3WwCfh4YSUqZc6LJ6UuFBWFa+0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779297929; c=relaxed/simple; bh=AXVHIOfgstHdeMZDcTzmaOfXjVt87eqMOEWSbUXrs9U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IODOuq3bbHg81KF0bqbfhVYmleXHZTFFnCLYk8Epo7LksLsAQ16TkpadfZnF4up/IIlHAkXopWo+Ofy4mmUz08N3udXpx9WpsBUm8MXB51U9RXR8fGJmTZ6xa1zf6/PGQhGAmw4ovBVYTEGZbkBk81P18LjmnU4Lr0mCvC06jiM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LA5yy1PC; 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="LA5yy1PC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B72C1F000E9; Wed, 20 May 2026 17:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779297927; bh=mcNDrDmBstKrAuojUtQsbuMIJ2sffocQB2LumpnuC14=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LA5yy1PC53Jiu2WqIQgLvtIN6iBIwuZdZNxuigqx0WFPBACjASXTNE5gRKST1XWBh Je7Ob1saAQSWAxQvU9D9+jy7d5IS7xVPmpj5KNcY4ws93E+0qkXZjvxJy7xhTA8vYp fX8E4oehXuMif8GxMB2n8QG4MBo4ceWohUbKUVfg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pauli Virtanen , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.18 176/957] Bluetooth: fix locking in hci_conn_request_evt() with HCI_PROTO_DEFER Date: Wed, 20 May 2026 18:10:59 +0200 Message-ID: <20260520162138.370956810@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162134.554764788@linuxfoundation.org> References: <20260520162134.554764788@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pauli Virtanen [ Upstream commit 5c7209a341ff2ac338b2b0375c34a307b37c9ac2 ] When protocol sets HCI_PROTO_DEFER, hci_conn_request_evt() calls hci_connect_cfm(conn) without hdev->lock. Generally hci_connect_cfm() assumes it is held, and if conn is deleted concurrently -> UAF. Only SCO and ISO set HCI_PROTO_DEFER and only for defer setup listen, and HCI_EV_CONN_REQUEST is not generated for ISO. In the non-deferred listening socket code paths, hci_connect_cfm(conn) is called with hdev->lock held. Fix by holding the lock. Fixes: 70c464256310 ("Bluetooth: Refactor connection request handling") Signed-off-by: Pauli Virtanen Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_event.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 6f77ab2629d65..b6b52b81b7b9c 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -3309,8 +3309,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data, memcpy(conn->dev_class, ev->dev_class, 3); - hci_dev_unlock(hdev); - if (ev->link_type == ACL_LINK || (!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) { struct hci_cp_accept_conn_req cp; @@ -3344,7 +3342,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, void *data, hci_connect_cfm(conn, 0); } - return; unlock: hci_dev_unlock(hdev); } -- 2.53.0