From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3000B21FF21; Tue, 12 May 2026 17:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778607970; cv=none; b=N+hU/5i69iX7K7OROaaLgetN8PtTmWfRXu2qHbtyJllJbhz8btHKuZy+ovKMnHDoq2ArShibeZS36AZuvhZDZnWzZTcRUT7ETXUElgSqe4ygefTCkOzV+z8YgWSTIPDMTTcwXZeluMSTdnbfOozCNkiL24lUZJCRCzaN4HYjTnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778607970; c=relaxed/simple; bh=7d0nH+sbVkEPlJSAaSlzIMWl8hi2j/8YYyIGhIOXIYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eoFHLQSz+XI2zkvG7+ro5cwKHLN4wpRamvVKwDSt01kv+XcMvT4wsI9HoB+69WOkmBN3uOXydxxQRR5xK7Kop94X2dl9D3MdG//qUOlf3THN1XJBkmgNU1vAmiN7BxQEyhNPbbSyo5tfC2v40kDZcV+NZurXjbd9rLHBZU9/Tg8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oEBtZrLD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oEBtZrLD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAF71C2BCB0; Tue, 12 May 2026 17:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778607970; bh=7d0nH+sbVkEPlJSAaSlzIMWl8hi2j/8YYyIGhIOXIYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEBtZrLDhn0Ha9AaXeLOIdxEGjWZbvcGOT+OaY69Cl//SXqxmbTVNh0w38RlogHMz D8p22TpjTSHGniJiF+1jZbqjA4MkXnsX9xUe+adCFfAJcn2ixBJOGywKOtEBvp9JgP yfkFod2vzstn1FoXcjbsW0fGMiHMksQzF1BNlYxc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tristan Madani , Luiz Augusto von Dentz Subject: [PATCH 6.12 063/206] Bluetooth: btmtk: validate WMT event SKB length before struct access Date: Tue, 12 May 2026 19:38:35 +0200 Message-ID: <20260512173934.176477735@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260512173932.810559588@linuxfoundation.org> References: <20260512173932.810559588@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: Tristan Madani commit 634a4408c0615c523cf7531790f4f14a422b9206 upstream. 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: Greg Kroah-Hartman --- drivers/bluetooth/btmtk.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) --- a/drivers/bluetooth/btmtk.c +++ b/drivers/bluetooth/btmtk.c @@ -654,8 +654,13 @@ static int btmtk_usb_hci_wmt_sync(struct 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); @@ -671,6 +676,12 @@ static int btmtk_usb_hci_wmt_sync(struct 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;