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=1796379371; b=CVTU30e3cVJv8K64RganSQLjKlCEcsOuErYh6f3uGps4JrtGKHm1dfFarR8yTiE+yhux nm/+5XJK00DnEbUf8zXwoZsAM/xrMokpeOql3IDUQc95/DdsVWlesG7H6YHeFuAZynH21 cmhRhNgkWR55AECokm0IzZrOTs0zQ2ReZk37VnHIYebkyhLi+ciQWFgchoZIrVcmAFVr3 m347TmpaoG8HoxwRZb5dTm2nRoJApq4tDhGCXZBqIFa3W3/CcdJVM0xaVIm/DyWnF88JL WtPB9S0UbArHjbIjirBC6v8EEp4z5uPzdcehsBQ9g+C70sI6pB1rckSmCNZOHdGj1/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379371; 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=ITi9Y3RJmOtt5C3BxuyleyBj0Aq8n6qIe7uH9QMvhYo=; b=QvkhB64ArgZRfFiQp9Hx9jsl13llVR6S3yMKXA7MeTX2x10lIiCUh3C2riwTZupYYOcy y29KG9frkbNZNLORruj7cU0DQ5vm+c0a7z8e41V0Ntusd32rs4JqRdc+nbZxqAYa4TXfL IN6QKJoOgjzoea9zvQOzJpDUKbKC0GsjAEznMWmuw4NWt0NOBG1NASDw/URznAxnH1PxG bSOyiA4+cIUTLR5t54WqeRmgujt8J56M8JwdjoCShKPvs6AO47ztVppofe8YcXM112qfr UVoarRIfGpW9QpEu75DpeQPBMPKLzyV4b2VmoQMa2hcHfTM0H5l16cMYTGWRFSTenrA== 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=JoENFTTR; 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 31B1B606A322; Fri, 4 Dec 2026 10:16:11 +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=JoENFTTR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C2E91F000C2; Fri, 4 Dec 2026 10:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379371; bh=ITi9Y3RJmOtt5C3BxuyleyBj0Aq8n6qIe7uH9QMvhYo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JoENFTTRUvk/9k5157xs2YKk24puhT1IepuGbp3cMR+u1BgAiFb0VuXEHW0YzxlwH K13PhYNKCm0+9BIMsclMKgJB8pX88SNWbEToj34AFJC+Wfr98ChsisY6O9jxUJTwNo NNrbFNxmB505E8rUtOOKbsHyLlUiJzRmf6c2fVYE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bin Yu , Cheng Wen , Luiz Augusto von Dentz , YuanZhe Liu <25031212351@stu.xidian.edu.cn>, Sasha Levin Subject: [PATCH 6.18 032/703] Bluetooth: btusb: fix use-after-free in force_poll_sync Date: Fri, 4 Dec 2026 18:58:51 +0900 Message-ID: <20261204100628.450392288@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: YuanZhe Liu <25031212351@stu.xidian.edu.cn> [ Upstream commit 868c886f45f7c10dc888b94c6993352702a84d04 ] The force_poll_sync debugfs file uses the driver's struct btusb_data as its private data. The file is created under hdev->debugfs and is removed only when the HCI device is released, while btusb_disconnect() frees btusb_data unconditionally. The HCI device can outlive the driver data, for example when an HCI socket still references it, so reading or writing the already opened file then dereferences freed memory: BUG: KASAN: slab-use-after-free in force_poll_sync_read+0x129/0x140 Read of size 1 at addr ffff88800cfb7038 ... Freed by task ...: kfree btusb_disconnect Remove the debugfs file before the private data is freed. debugfs_remove() waits for callers that are already inside the file operations, and any later access fails with -EIO instead of reaching the driver, so the force_poll_sync file can no longer dereference btusb_data after it is gone. Fixes: 800fe5ec302e ("Bluetooth: btusb: Add support for queuing during polling interval") Cc: stable@vger.kernel.org Co-developed-by: Bin Yu Signed-off-by: Bin Yu Co-developed-by: Cheng Wen Signed-off-by: Cheng Wen Signed-off-by: Luiz Augusto von Dentz Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn> Signed-off-by: Sasha Levin --- drivers/bluetooth/btusb.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 6143414711c5d..99bee6e6d286f 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -1018,6 +1018,8 @@ struct btusb_data { int oob_wake_irq; /* irq for out-of-band wake-on-bt */ + struct dentry *force_poll_sync_dentry; + struct qca_dump_info qca_dump; }; @@ -4418,8 +4420,9 @@ static int btusb_probe(struct usb_interface *intf, usb_set_intfdata(intf, data); - debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, data, - &force_poll_sync_fops); + data->force_poll_sync_dentry = + debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, + data, &force_poll_sync_fops); return 0; @@ -4455,6 +4458,9 @@ static void btusb_disconnect(struct usb_interface *intf) if (!data) return; + debugfs_remove(data->force_poll_sync_dentry); + data->force_poll_sync_dentry = NULL; + hdev = data->hdev; usb_set_intfdata(data->intf, NULL); -- 2.53.0