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 4F8F34E0B63; Thu, 17 Sep 2026 18:13:38 +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=1789668819; cv=none; b=BaifU5LsKCgwRTqFBCao6K3wHvXQ0zns+j3D9pwCMjM/gIltp0pQ1CCwWt6dyPrt4o4MBHr0YmmrdQ73rtUW+nj8WiE3MFgbGH6r4LUX3XHUF08ybDZXiTnAhGVpX+rtXIPHIMKp+R93BwzKhW87LiXYXH2fylKPyinTu/dA51Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789668819; c=relaxed/simple; bh=9ZVuEi2gJEXrw7kHfoFJaCl4zz/RFHhAAGW0RctlDAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fNwOK1iKEkQxzT06PVZxSskmDteain77VYJw5prrN475nma6mX0iZ7tZMPrXTIbn1ZDbK+OKp7GWGPG1vcRkkdzG8sNhLjXRLISPMmW9CXAamdb/zWPQisQNdAJK9xoZmJhzi3cIBZD4HKIaZ7jR969tVS/eyRQn/23to+kENqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S2nmgSXF; 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="S2nmgSXF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A56011F00893; Thu, 17 Sep 2026 18:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789668818; bh=TntQs+A99a/8oPbp+G+ePt8gMZiDjcbI6xD+hh96WHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S2nmgSXFv7PPkTcdftUck61uG0A7HaeSehMkDhkfa/EmRsj51g/Tgq4O8mwa6kYAZ QrOCGrOZqyriNlI0/2WyETR8nPq/7lqpOSljcbdDkX8hlwsSWePdWWkDphc28h1oFD i2CwS/PDaR4ruruPcslkFAeTk6zs+BHiHmkxlfAk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ali Ahmet Memis , Laxman Acharya Padhya , Kiran K , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.12 0550/1102] Bluetooth: btintel: validate version TLV value lengths Date: Thu, 17 Sep 2026 16:08:13 +0100 Message-ID: <20260917151553.647215972@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Laxman Acharya Padhya [ Upstream commit a086c0892969bf8a0151b0f12bd14a68827c88b2 ] btintel_parse_version_tlv() verifies that a complete TLV is present in the response, but it does not ensure that the value is long enough for the specific TLV type. A short value can therefore cause an out-of-bounds read through get_unaligned_le16(), get_unaligned_le32(), or memcpy(). Reject values shorter than the minimum required by each known TLV type. Also reject responses that do not contain the Command Complete Status field. Fixes: 57375beef71a ("Bluetooth: btintel: Add infrastructure to read controller information") Reviewed-by: Ali Ahmet Memis Signed-off-by: Laxman Acharya Padhya Tested-by: Kiran K Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/btintel.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c index c63246a60c6be..0efc2d9e787fc 100644 --- a/drivers/bluetooth/btintel.c +++ b/drivers/bluetooth/btintel.c @@ -546,12 +546,44 @@ int btintel_version_info_tlv(struct hci_dev *hdev, } EXPORT_SYMBOL_GPL(btintel_version_info_tlv); +static u8 btintel_version_tlv_min_len(u8 type) +{ + switch (type) { + case INTEL_TLV_CNVI_TOP: + case INTEL_TLV_CNVR_TOP: + case INTEL_TLV_CNVI_BT: + case INTEL_TLV_CNVR_BT: + case INTEL_TLV_BUILD_NUM: + case INTEL_TLV_GIT_SHA1: + return sizeof(u32); + case INTEL_TLV_DEV_REV_ID: + case INTEL_TLV_TIME_STAMP: + return sizeof(u16); + case INTEL_TLV_IMAGE_TYPE: + case INTEL_TLV_BUILD_TYPE: + case INTEL_TLV_SECURE_BOOT: + case INTEL_TLV_OTP_LOCK: + case INTEL_TLV_API_LOCK: + case INTEL_TLV_DEBUG_LOCK: + case INTEL_TLV_LIMITED_CCE: + case INTEL_TLV_SBE_TYPE: + return sizeof(u8); + case INTEL_TLV_MIN_FW: + return 3; + case INTEL_TLV_OTP_BDADDR: + return sizeof(bdaddr_t); + default: + return 0; + } +} + int btintel_parse_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version, struct sk_buff *skb) { /* Consume Command Complete Status field */ - skb_pull(skb, 1); + if (!skb_pull(skb, 1)) + return -EINVAL; /* Event parameters contatin multiple TLVs. Read each of them * and only keep the required data. Also, it use existing legacy @@ -571,6 +603,9 @@ int btintel_parse_version_tlv(struct hci_dev *hdev, if (skb->len < tlv->len + sizeof(*tlv)) return -EINVAL; + if (tlv->len < btintel_version_tlv_min_len(tlv->type)) + return -EINVAL; + switch (tlv->type) { case INTEL_TLV_CNVI_TOP: version->cnvi_top = get_unaligned_le32(tlv->val); -- 2.53.0