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=1796382340; b=BdnUeuijLrct9WuwEfrhj/X2xvCUAS431HGrXz9Y80FGwP7QTf4rACRMdha0PIf82S7G PSx8ByuHOt98qgKBindc8RYFJKBOeB76T3I3ryOrGzqt666ATJLRi9Z3ZyG0KBq8v2qA3 cjgnaPpc54RepcI1eAWuU3xYPfAXHYQ4VNQUxUoV7KA3zvAlfEKzCvxQYMG3nC9ebWE09 kcuekcCNv1qHT4V9UB0e0/6cb4tFh1UIJqECzebQrvwAOEnR2N/Usl/Nrm3A5MG/ZMuCN IXbcx6lYHPuQpTWfg+lrdppibkOfbD7iS8cuAuhpBdYnmPJApYvx95vcPZpcvWFREJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382340; 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=pDphmeUuGql4hE8Qcx6wz4166jQeP9l2KvcaL6mfuV0=; b=tdt//OlgRlLiseMildGYPy/i8J68p2KEcjriTv3f39+FFQih5/KhfyXQSRxgiTgcX/Vl Ak89IXc8B/auAEzml6a4sRG9FWpsjbcc0GPFBL2av6pVoiNxshKahV1nPFq8jsRvu/IYZ Vj8V248KZeYS8Sm/bQx3EgAxcxYB2aGKhDc2lTrkFb7YN/IyBA3BWeQe96c7VDSqES6ra 9/xQWKT/erG+jXUeFUohUAGa+pqpFeyLUw3mg3v0n1qwKP+fXnMg2F84IFx1rjk3vQXuO QXITnstSXQNMWJf4b5zWNjgZpTZ0pLFhsRkGrYZLUq0t1tT7fAyxylUmt51SfHKWNuQ== 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=zvJyoqKr; 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 BFCA4606A32C; Fri, 4 Dec 2026 11:05:40 +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=zvJyoqKr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FBA31F000CE; Fri, 4 Dec 2026 11:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382340; bh=pDphmeUuGql4hE8Qcx6wz4166jQeP9l2KvcaL6mfuV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zvJyoqKrdVn+lFJ3SXoKLgG6ysVRdKWgOPql4TG+qHO3NyJ3o+MstYNWeMk36f0Zv 42MGo2pRUEZUS/mKIKd49Z7EjZhlF8gR2fxraz2u41036WqXd5ivppJ7A+idnvTPrK 1L5/EkvbUdEt6qimQAQ/yCIWZG4iP5Lx9zIUrLLI= 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.18 405/703] Bluetooth: hci_qca: clear qca_memdump when discarding dump packets Date: Fri, 4 Dec 2026 19:05:04 +0900 Message-ID: <20261204100638.609046123@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-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 @@ -1130,6 +1130,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;