From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384447; b=SHqsdO/6MR597hRPngFvXTaJy84E6NVaPqX+Cdkw4s3c57yTZ9XDmQGUO4807c5/wa8T gr7VKSxkoS8tt6flyVgWBPFhkJPk2B5HYYs+bCqoNM4ZzAI+tvWC2kKuiNFycXdEMzRDw RQYC+kaDJ7qNpEGR3bDPiU/xbrDqSAVyAtutVFwjJH7gpjkFoPqEVxEn6aVVN3e7zBJ2V fdbw+IU8D+NgBy81CD0m6lnwX4p/EPvte7jte1Qs9UQatD21AdAiycm3TK8z12DaIw3g0 RnjdCjpXBzRHg2z3aqMkKZ39fOUYOl0paIApePL3jE8S4scF3m8vpwXiwL7AFyoAx+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384447; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=0TLEhC9i07ar5PlWYxqB2z7f8YtdxMZLMLX4ZOHzLKQ=; b=eut5ubIPS+ZijGGMjsC2I7Wimjftq3ZAxsO0ipBoAtOrC8jmbkQRR6c1I7zTj7PRxIGO mJ0JJQRS6i4dQdPhYR0+M9LWTNaDhX2N12cvk/uEa+iuY+mDtxO0BVUgZkNYEUvymEXU5 jx0ABWL9XuVEpWWEEbr5AOmC8TFDe7uz5b8bIdlmFG5kErSYqCxgk4hv4OnZPDEosbDyP +K4WdcarmQkiIU2VSYYcEjh2CCZGvmzn4h3ka0txRDPBnVOS+t/MblTihqs+UwNGV1mpY c1Fia3CIUz0cD/nURkMlgG7xrM4Cw8N588VUe5e19JcQ9s1XBpO0KhGDeEMtd1rTQIA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oNUVOhrv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BDC8606A322; Fri, 4 Dec 2026 11:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oNUVOhrv Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02CF81F000C2; Fri, 4 Dec 2026 11:40:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384447; bh=0TLEhC9i07ar5PlWYxqB2z7f8YtdxMZLMLX4ZOHzLKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oNUVOhrvl/GhK8KJ+9OW5oOJ4NqVT4gtBeZkwpHjC5/BzNY/7XBwSIhq60b6YgN2S H0ZgO3h4T1kQtz+y4efHd/pHNlvE/AQYIXjxgDf4AYgnUIAGexPd8qfBwB+uJCWjR2 9tygEbLG0jRZwZ8/kAtIDS0FZatHTuOSiEdFJBKw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Binbin Deng <18983559317@163.com>, Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 0112/1167] Bluetooth: hci_core: Initialize IRK before publication Date: Fri, 4 Dec 2026 18:52:19 +0900 Message-ID: <20261204100705.012917442@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Binbin Deng <18983559317@163.com> [ Upstream commit f0cf5a24cefeb629876bd15d668ff062c8655e28 ] hci_add_irk() initializes the identity address and address type of a newly allocated IRK, publishes it on hdev->identity_resolving_keys, and only then initializes its value and RPA. RCU readers such as hci_find_irk_by_rpa() and the debugfs identity_resolving_keys_show() can traverse the new entry during that window and see a zero or partially initialized IRK. The race is reachable by racing an IRK addition with another CPU resolving or dumping IRKs. In particular, userspace can issue MGMT_OP_LOAD_IRKS while another process reads the corresponding debugfs file or triggers RPA resolution. Initialize the IRK value and RPA before publishing a newly allocated IRK. Existing IRKs remain published and continue to be updated in place. Found during a static-analysis-assisted audit: candidate sites were surfaced by a Coccinelle rule, and the reader/writer paths were confirmed by LLM-assisted (GLM-5.3) code inspection. The issue was not observed at runtime; it is identified by code inspection only. Fixes: adae20cb2d20 ("Bluetooth: Convert IRK list to RCU") Assisted-by: GLM-5.3 coccinelle Signed-off-by: Binbin Deng <18983559317@163.com> Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/hci_core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 5f58b24ec900b..d8e95cd09d091 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -1347,9 +1347,10 @@ struct smp_ltk *hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 val[16], bdaddr_t *rpa) { - struct smp_irk *irk; + struct smp_irk *irk, *old_irk; - irk = hci_find_irk_by_addr(hdev, bdaddr, addr_type); + old_irk = hci_find_irk_by_addr(hdev, bdaddr, addr_type); + irk = old_irk; if (!irk) { irk = kzalloc(sizeof(*irk), GFP_KERNEL); if (!irk) @@ -1358,12 +1359,14 @@ struct smp_irk *hci_add_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, bacpy(&irk->bdaddr, bdaddr); irk->addr_type = addr_type; - list_add_rcu(&irk->list, &hdev->identity_resolving_keys); } memcpy(irk->val, val, 16); bacpy(&irk->rpa, rpa); + if (!old_irk) + list_add_rcu(&irk->list, &hdev->identity_resolving_keys); + return irk; } -- 2.53.0