From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796383787; b=3UWa/93whjgWGWvSt24lni1Pa0+SbL/FIWUb6P4n6QvTuSAlL/YVUCreBUErWpXpg1Jj l2KJBEl0+MyqSFCgVVDg0Myh8LiJI6T5Z+HduldfPzC6AIP19Kxeuqhrb8QxfpjAXKf+H TK5cZWeeCI0MoByI741hMRH334Q+DYpS+hB0R8BzbFZv2E60Ca/2qcrkQbnnqVtGpwfEN N+YT+qAv4PFquEDbXl2MPqDT8IKG0WM6X6umFO1wRGopGjcCqoUFLmd0WINl8yWvPl1eQ zXaC/sh6zS7vsWxkK+3OESHvl0lP/0xR504giGWr3WlrLlA1oEc/4+fiRopAM4/kNjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383787; 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=pgsHPDohokenvEKm3T5ns1Ob23xMW6NwQ/DDsFVN1ec=; b=xDAp+kBv8V7n7waSEgfwWrPIwAnCNE9KBMVW0osgZAC5dk8Etown/3U2RoO6FsmWR4ql k12gDO7ATt8mCmXv0PNiMPxTMObBJW+6FB3wr5Qc7sWHaRnMVZBdDt3OzBlfUTgythUCT rh4gQ14EAmHeBPZEuDf5Oz8PPYku+UcoYO+/yxoI3drYz4qLKyr/maW7d88fhfowitwkI PxjyIrwlHytXA4lH+8a9acIbfiPZS/KjMXIlvt18ugnc+cvJHw6hd9aS6PijpxWKy9Rs0 i9Vi3MWtWMvbdzKFlJk64YyhGj71WhgufKvl3FNJm4cRPLiR3b/4BYxV6lR2N6qIi7g== 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=gJ7Fjb9d; 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 2300C606A322; Fri, 4 Dec 2026 11:29:47 +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=gJ7Fjb9d Received: by smtp.kernel.org (Postfix) with ESMTPSA id 502831F000CE; Fri, 4 Dec 2026 11:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383786; bh=pgsHPDohokenvEKm3T5ns1Ob23xMW6NwQ/DDsFVN1ec=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gJ7Fjb9d4FR6AsTKo+PatI1uDby7NHn+ybGL4pblkxWBz6mjuf7IshM0/jB/TBt9A F2pjQqONUL4FXooMuJ7I/zePzgocHrw3DODnjtOmqp9YyZUGAQkEnpeW/es+HY+BG2 UbkqePOhfR21Qg1sZWCf1VPhaWNAQgtUvpcC2YRc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Luiz Augusto von Dentz Subject: [PATCH 6.12 365/555] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Date: Fri, 4 Dec 2026 19:06:48 +0900 Message-ID: <20261204100623.889590358@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos commit 45a25a1bfd267d9e420119a48e5291d7882395df upstream. qca_controller_memdump() frees qca_memdump when a memdump packet with a non-zero sequence number arrives while QCA_MEMDUMP_COLLECTION is not set, but leaves qca->qca_memdump pointing at the freed object. The next run of the work reads the stale pointer into its local variable, skips the allocation and uses the freed memory. Another packet with a non-zero sequence number frees it a second time, and a packet with sequence number 0 writes ram_dump_size, current_seq_no and received_dump into it. The original code cleared the pointer here; the assignment was dropped when the condition was changed to test QCA_MEMDUMP_COLLECTION. All other places that free the structure clear the pointer. A controller that sends two memdump events without a leading sequence number 0 can trigger a use-after-free or double free of a kmalloc object. Found by LLM-assisted source review. Fixes: 06d3fdfcdf5c ("Bluetooth: hci_qca: Add qcom devcoredump support") Cc: stable@vger.kernel.org Signed-off-by: Joas Antonio dos Santos Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- drivers/bluetooth/hci_qca.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -1115,6 +1115,7 @@ static void qca_controller_memdump(struc if (!test_bit(QCA_MEMDUMP_COLLECTION, &qca->flags)) { bt_dev_err(hu->hdev, "QCA: Discarding other packets"); kfree(qca_memdump); + qca->qca_memdump = NULL; kfree_skb(skb); mutex_unlock(&qca->hci_memdump_lock); return;