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=1796386066; b=unjcOBxuiLUkd+0OyYCXuY2U8bWsaQQ6+yEjmnXYYsPYN1tvFWPgnDfcvvqdlyO3g7d7 iujeNUtS12MzWKq3w+B5ioEPS+AXRl/0PZ89VnaTburt7fiKSK0cFajIlLCfnpNmsRwlS uB8UZJ4NdFNPZLbqPfYeq4qa3gj/AdjrmhQh3kQ2FvGWzCwFEMFmCAh2jn0MgTN58LMd/ CIrSKnxcaAf7qzZwb+JvVzNWUIwnckcey6f0b9aWg6YnXcrQXc5qVSzJXmwmAtM1f+gJF /RhDEAnNeilX9/RrkLPMbGOMx91YAp3CnYYa3ZdnlQjq+DA7oFw6H9g4fw7QcutParQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386066; 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=4ecpY3iwEIWRqvMniPXCXra1W0NrJ9aeK8CgLPh7Pq0=; b=Er1dO3bns6pDgynMPFyGGvsXGHznW6G8NpxUDmdRZb3LnkcULMsDX4Ol8/sayC2R+jK5 6dn/PuSDKRkZ2kMw+2JdunWn5zl1M1xf2PQaiYfUbh9oq08cLD3ZC9ceKWXpD1tkuGrbk L3ZyjwwEVQQwCpP31mwehS1UxtvbeKLzpDXS7GFAueOdNjpZjwnUy4kXBSTuwd3JCxgAN t0FSKuBdzr6IZonGfC51z2bThJmsoxNFKfoGsWGSpdTpdPYDeipbrpK+LCAonkqZ0LCdO UER66B1H0wsKavFhDwQz3jbQXqI6cj7p190DhxFaYaKJGHLpT4h3bxaT11L6zAHt/mg== 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=z1c3f5ZN; 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 111DC606A322; Fri, 4 Dec 2026 12:07:46 +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=z1c3f5ZN Received: by smtp.kernel.org (Postfix) with ESMTPSA id 781EA1F000C2; Fri, 4 Dec 2026 12:07:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386065; bh=4ecpY3iwEIWRqvMniPXCXra1W0NrJ9aeK8CgLPh7Pq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=z1c3f5ZNJGybQEHPOae0Iu5q3Na6GG38rrnTQMWVLKsasZ3lhn6LWtb6VtOlzNQpv LLjmDMABmapAOg4DdncEv0q+0ICtkeEvx5lvY67T+WOwOgwDx8cFAoOJXbMqV3koKY Rl7BXkoLirlOftuMLH3/NemvdUSRpB8epGB7ZwFI= 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.6 0761/1167] Bluetooth: btusb: fix use-after-free in force_poll_sync Date: Fri, 4 Dec 2026 19:03:08 +0900 Message-ID: <20261204100721.901940662@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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 11b633e666a2e..31b07b2208b01 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -949,6 +949,8 @@ struct btusb_data { int (*disconnect)(struct hci_dev *hdev); int oob_wake_irq; /* irq for out-of-band wake-on-bt */ + + struct dentry *force_poll_sync_dentry; unsigned cmd_timeout_cnt; struct qca_dump_info qca_dump; @@ -4105,8 +4107,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; @@ -4142,6 +4145,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