Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: hci_codec: validate vendor codec count length
@ 2026-08-23 16:16 Laxman Acharya Padhya
  2026-08-23 17:18 ` bluez.test.bot
  2026-08-24 14:28 ` [PATCH] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 9+ messages in thread
From: Laxman Acharya Padhya @ 2026-08-23 16:16 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: Marcel Holtmann, Luiz Augusto von Dentz, linux-kernel,
	Laxman Acharya Padhya, stable

The Read Local Supported Codecs parsers consume the variable-sized
standard codec array before parsing the vendor codec count.  Although the
initial reply-size check includes a vendor count byte in the fixed layout,
it does not guarantee that the byte remains after the standard codec array.

If a controller reply ends immediately after that array, calculating the
vendor codec array size reads vnd_codecs->num beyond the skb data.  Require
the vendor codec header to be present before using its count in both
command variants.

Fixes: 8961987f3f5f ("Bluetooth: Enumerate local supported codec and cache details")
Fixes: 9ae664028a9e ("Bluetooth: Add support for Read Local Supported Codecs V2")
Cc: stable@vger.kernel.org
Signed-off-by: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>
---
 net/bluetooth/hci_codec.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/bluetooth/hci_codec.c b/net/bluetooth/hci_codec.c
index 5bc5003c387c..99394a3348c7 100644
--- a/net/bluetooth/hci_codec.c
+++ b/net/bluetooth/hci_codec.c
@@ -165,6 +165,8 @@ void hci_read_supported_codecs(struct hci_dev *hdev)
 		 + sizeof(std_codecs->num));
 
 	vnd_codecs = (void *)skb->data;
+	if (skb->len < sizeof(*vnd_codecs))
+		goto error;
 
 	/* validate vendor codecs length before accessing */
 	if (skb->len <
@@ -233,6 +235,8 @@ void hci_read_supported_codecs_v2(struct hci_dev *hdev)
 		 + sizeof(std_codecs->num));
 
 	vnd_codecs = (void *)skb->data;
+	if (skb->len < sizeof(*vnd_codecs))
+		goto error;
 
 	/* check for payload data length before accessing */
 	if (skb->len <
-- 
2.50.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-24 16:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-23 16:16 [PATCH] Bluetooth: hci_codec: validate vendor codec count length Laxman Acharya Padhya
2026-08-23 17:18 ` bluez.test.bot
2026-08-24 14:28 ` [PATCH] " Luiz Augusto von Dentz
2026-08-24 14:40   ` Laxman Acharya Padhya
2026-08-24 15:01     ` Luiz Augusto von Dentz
2026-08-24 15:20       ` Laxman Acharya Padhya
2026-08-24 15:31         ` Luiz Augusto von Dentz
2026-08-24 15:57           ` [PATCH v2] " Laxman Acharya Padhya
2026-08-24 16:54             ` [v2] " bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox