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=1796389251; b=uDCFnwhoNi/LUXETpweZAS3O+8cZn7JBXJaK517/htUXOwUHXIuUlaSYPk8qst66sR/p ntyVHyIvg85Fal92VJLxIVCImzZNJKWuGfWFtkTDlGNpN6f+m20gRe/q3pKOULrYOGFwT Bw7mjTcD/HF2UN1A7YFehwp96C5Dbpn1czQavVgbjGBnnmjw/vMYlurOHdMOC9LcEYSaH uuVWUJ2krJmHW8YSmdrvv4k2DAo69atN1QX0UDry6MU3OzqoBVjIkAiBszrTe5ahEWzK9 kLsg0bApG/hQqM32DHSqD4Zu4CbHaANz9yxiT/8PXAwKYZvmFRhUv88pEIM8xeLXOig== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389251; 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=UxZm0VbbsPMAoxBbb/458F+QRLxh6Y2WgBxN5YV+o8E=; b=wKsU5QTx8BL8ohHLzxRWRYeA8sZbp6JX7nRvgThKPVBIHDvL6j42d137hSqoD470jchM twQy2LQSLKjwRTxGBfRtHLT1vZJuPEL6dr3jPB1B8SQSnlGuDSO0IDazs76BU0sEEd5XC LYz+UUCg4zD1S6HL6G99oao5MwwhCVmEQCwSKbgcjaQgK/OmTBu6d7OrKlxJPjytqP3+s 2Geli7ZuVIn+OF5g4QR4SyrLAWsj2cV+sq3BasuyPv+4zOv9xI4XYqLxUB+eVo6heBngY 9CW1k00Aq0wsbgsRcUgDu1c5/GWjgBJjM4XezqlDaCtoAdPIOokxQOmWNrwXfd/DiAQ== 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="z1m0/CrU"; 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 3166A606A322; Fri, 4 Dec 2026 13:00:51 +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=z1m0/CrU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AB1C1F000C2; Fri, 4 Dec 2026 13:00:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389251; bh=UxZm0VbbsPMAoxBbb/458F+QRLxh6Y2WgBxN5YV+o8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=z1m0/CrUpmkW0bqpeKZnsZiYQiRYA3fZubveTnWzfljqQKd0abnf5OmGvJZmqKTxN 6/4uJlio1QsZfmI8/+S+EqrZFr2dG9lEqGwCTMaxJZyGNth0d87nb+ylhgrhMp70UK iASQbs1E6cVyafuxF+8vLZ773sJ4R7BkI2RJ+t6s= 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.1 0921/1059] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Date: Fri, 4 Dec 2026 19:07:32 +0900 Message-ID: <20261204100707.878544065@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 @@ -1081,6 +1081,7 @@ static void qca_controller_memdump(struc if (!memdump_buf) { bt_dev_err(hu->hdev, "QCA: Discarding other packets"); kfree(qca_memdump); + qca->qca_memdump = NULL; kfree_skb(skb); qca->qca_memdump = NULL; mutex_unlock(&qca->hci_memdump_lock);