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 0065E31DD97; Thu, 2 Jul 2026 16:48:41 +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=1783010922; cv=none; b=TjO78XmRKiNPg1XvB6BLxA04AEG5YPFqVBtDOAZRAtfn/wO6Zc1aoK/yrJN05SljNpYEgeZWCaYj4JTFYYktY4170wR3s6FTUyfwMwLZUiSCe/GrXcX16rDAxCS1eHw9CruOpls1GhrP3F8B85h0ngWS/Vd996XMIIzkcyszLks= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010922; c=relaxed/simple; bh=VPVC/L6JhQzAlrhgM+on2FDCzg4cUZA7vZUa04Uvp7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ccxeXt/H3TH/rUyClKXbk3pMcjDRwTnuGvt9STllQzF1rkspKXqAyeFeJc4BMwOZFz3cWXaluZTW7WtvUsuQTDHLpKMz42GWjmPh9iW4FUsyuD5irNyEqnDhj6kDQdRE8Ru038ssoXRhgE7GNFwimo+j6RFP0NJyAvk37eGCuVM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U4meRvsY; 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="U4meRvsY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 653751F000E9; Thu, 2 Jul 2026 16:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010920; bh=YyUyEgQLfgyrnR4/QgmByLcQwLZEoVUXcPt/8BXsMWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U4meRvsYzwo/P++rf8UHoVo/ycO8Ktvj7Bkaw+d3qsnfeDHeVD93ECovtJo5dpiPm AGt42SMgbtciMfobDVSO6nSqqnJwaa6E7KTzu9oupetcBqmme8wDb1CDsX/8ry1b39 6Y85cwH5niTU5kDrh9gBVFtABzlKdicLYIk9mdpc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tristan Madani , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 6.6 086/175] Bluetooth: btmtk: validate WMT event SKB length before struct access Date: Thu, 2 Jul 2026 18:19:47 +0200 Message-ID: <20260702155117.592717789@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155115.766838875@linuxfoundation.org> References: <20260702155115.766838875@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tristan Madani [ Upstream commit 634a4408c0615c523cf7531790f4f14a422b9206 ] btmtk_usb_hci_wmt_sync() casts the WMT event response SKB data to struct btmtk_hci_wmt_evt (7 bytes) and struct btmtk_hci_wmt_evt_funcc (9 bytes) without first checking that the SKB contains enough data. A short firmware response causes out-of-bounds reads from SKB tailroom. Use skb_pull_data() to validate and advance past the base WMT event header. For the FUNC_CTRL case, pull the additional status field bytes before accessing them. Fixes: d019930b0049 ("Bluetooth: btmtk: move btusb_mtk_hci_wmt_sync to btmtk.c") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- drivers/bluetooth/btmtk.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btmtk.c b/drivers/bluetooth/btmtk.c index ad8753dda826bb..5c6f4d4b2e7f0c 100644 --- a/drivers/bluetooth/btmtk.c +++ b/drivers/bluetooth/btmtk.c @@ -655,8 +655,13 @@ int btmtk_usb_hci_wmt_sync(struct hci_dev *hdev, if (data->evt_skb == NULL) goto err_free_wc; - /* Parse and handle the return WMT event */ - wmt_evt = (struct btmtk_hci_wmt_evt *)data->evt_skb->data; + wmt_evt = skb_pull_data(data->evt_skb, sizeof(*wmt_evt)); + if (!wmt_evt) { + bt_dev_err(hdev, "WMT event too short (%u bytes)", + data->evt_skb->len); + err = -EINVAL; + goto err_free_skb; + } if (wmt_evt->whdr.op != hdr->op) { bt_dev_err(hdev, "Wrong op received %d expected %d", wmt_evt->whdr.op, hdr->op); @@ -672,6 +677,12 @@ int btmtk_usb_hci_wmt_sync(struct hci_dev *hdev, status = BTMTK_WMT_PATCH_DONE; break; case BTMTK_WMT_FUNC_CTRL: + if (!skb_pull_data(data->evt_skb, + sizeof(wmt_evt_funcc->status))) { + err = -EINVAL; + goto err_free_skb; + } + wmt_evt_funcc = (struct btmtk_hci_wmt_evt_funcc *)wmt_evt; if (be16_to_cpu(wmt_evt_funcc->status) == 0x404) status = BTMTK_WMT_ON_DONE; -- 2.53.0