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=1795618190; b=I9e71zZpQtrijCQaZqny8IGzdfLfczFQKxVfCI7aLBmA2kRG8hnv1EGzIpjPSarkiF97 exNQbcXybAootvBTqdraDGoxSNYpfXlfd99eHUcIVPu5Rp1l9lAOq1YGW30wCoCiA/SMA Y4fy9tK7cVa2puu06PkWKSMrWIPufK4270EW5+Qh6DQEIOh0HuJEx1qYhAPEGKFycJNDz T5AT8kFZdxEp8jgXduZcX5Jok70KXpeszbAiKSOWEl81B977OiyvCFKuU41k9VkH7sl1i vX4/eLJ3KDcmLB4j/F59lQjS+hkhk2swTE9r8DLNkpijKEHGxBP/Tq3UwcdH20CvIdw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795618190; 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=FlNGZWvgG+8kE0FR51ExDOgpeGnkCuYVRKbONqkd/5Q=; b=Tr2j/ezO1oPmOKED0j8fi1GOkUJi+BzsoJZAMnxPWwbBQCbdvsJV0hy53e+gvOIFgdPm mUp4NoZrSKEdYIeAwatkORIvR5lREIE1Dptv52o2IFMzgKqm2w3/DleIcilmoz73LY62w 0TPaV24hDCPHa7L/S8yToiELo0TuCdqrrzlxStLoRqgIGPm0XC6PwtyeIldgyd9HhKM+B ze/OPfclf/I2CCy/CcOfTlXO95IIOXqwMh5dvtfjFBAZIwF1XYIn5tVRZJPlLG7pMPQUp /C8H0M8NugkzEAB1bbaI8NQ6dZAbTg35fTmBik+15R8Palx9hr/KltOmxqhypVSoj0Q== 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=kzlA+tVH; 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 C7B35606A323; Wed, 25 Nov 2026 14:49:50 +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=kzlA+tVH Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9F951F000C0; Wed, 25 Nov 2026 14:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795618190; bh=FlNGZWvgG+8kE0FR51ExDOgpeGnkCuYVRKbONqkd/5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kzlA+tVHBaSTmg0bzGlCTf0mstVaKHBY1jIoToKFUOWDQ8rBiHasTh9iVLKN/XpDn NXMgKTjbx/xzrYKw1ByCgNWa5GX60QUftv2f/OUkDfqsKVO+0aPBNbRI6REQkSq2zp X5uFKT2SYGoR4ctBEhrz/BV4d9RKtRmW+qBkubKU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hao Qin , Wenlong Tian , Chris Lu , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 7.3 0200/1005] Bluetooth: btmtk: bound the ISO payload length by the controllers MTU Date: Wed, 25 Nov 2026 15:25:38 +0100 Message-ID: <20261125143826.425332656@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143821.729802100@linuxfoundation.org> References: <20261125143821.729802100@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Lu [ Upstream commit d015faf684129a276f2137ad2e11c6c985294648 ] btmtk_recv_isopkt() bounds the Data_Total_Length reported by the controller with skb_tailroom(skb) < hci_skb_expect(skb). That keeps the reassembly inside the skb, but it enforces no protocol limit: the head allocation is rounded up to the next kmalloc bucket and skb_tailroom() reports what the bucket can hold rather than what was requested, which is several hundred bytes more. An oversized length therefore passes, and the parser keeps pulling bytes out of the following transfers to fill it, swallowing the real ISO packets they carry until the frame is handed to hci_recv_frame(). The controller reports the largest ISO_Data_Packet_Length it will send in LE Read Buffer Size [v2], which hci_cc_le_read_buffer_size_v2() keeps in hdev->iso_mtu. Once that is available, bound the length by it and size the receive skb to hold that much plus the 4-byte header. HCI_MAX_ISO_SIZE is kept only as a fallback for the window before the command completes. Keep the skb_tailroom() test as well, because a fragment started before hdev->iso_mtu was populated sits in an skb sized for the fallback. Fixes: ceac1cb0259d ("Bluetooth: btusb: mediatek: add ISO data transmission functions") Co-developed-by: Hao Qin Signed-off-by: Hao Qin Co-developed-by: Wenlong Tian Signed-off-by: Wenlong Tian Signed-off-by: Chris Lu Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/btmtk.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c index 1745e0421ca6b..a81ed47c2fd1f 100644 --- a/drivers/bluetooth/btmtk.c +++ b/drivers/bluetooth/btmtk.c @@ -1162,8 +1162,15 @@ static int btmtk_recv_isopkt(struct hci_dev *hdev, void *buffer, int count) struct btmtk_data *btmtk_data = hci_get_priv(hdev); struct sk_buff *skb; unsigned long flags; + unsigned int iso_mtu; int err = 0; + /* The controller reports the largest Data_Total_Length it will send in + * LE Read Buffer Size [v2]. Fall back to HCI_MAX_ISO_SIZE while that + * command has not completed yet. + */ + iso_mtu = hdev->iso_mtu ? hdev->iso_mtu : HCI_MAX_ISO_SIZE; + spin_lock_irqsave(&btmtk_data->isorxlock, flags); skb = btmtk_data->isopkt_skb; @@ -1179,7 +1186,8 @@ static int btmtk_recv_isopkt(struct hci_dev *hdev, void *buffer, int count) if (mem_is_zero(buffer, count)) break; - skb = bt_skb_alloc(HCI_MAX_ISO_SIZE, GFP_ATOMIC); + skb = bt_skb_alloc(HCI_ISO_HDR_SIZE + iso_mtu, + GFP_ATOMIC); if (!skb) { err = -ENOMEM; break; @@ -1213,7 +1221,13 @@ static int btmtk_recv_isopkt(struct hci_dev *hdev, void *buffer, int count) break; } - if (skb_tailroom(skb) < hci_skb_expect(skb)) { + /* Reject a length the controller said it would never + * send. The skb_tailroom() test is kept because a + * fragment started before hdev->iso_mtu was populated + * sits in a smaller skb than iso_mtu now allows. + */ + if (hci_skb_expect(skb) > iso_mtu || + skb_tailroom(skb) < hci_skb_expect(skb)) { kfree_skb(skb); skb = NULL; -- 2.53.0