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=1796388600; b=ooMfWHN9Dk3H5yINh5HAq+QpctkeosroK/vggdIotyxrG4INJgB+e05EkKZwCObjWrtw 6aBcks73AtJpXBKjRLUZ0QP67+Wpjj66lmxCs3kWjKJQO/zNA5aDWWEI5SEpqy/QwyMhN 8JdWLaYPsIVTUiNnzR2eXTPor5ke/+mcWgTVVxeczFV1Xe3efoy7OOwTR/UYADDoL5IKF xEMGjBuIxCrUUtgEo29LH9tyVIXfmfqeXUgiuCU6FcnxXHI1LFMvIdhGUNgUvIsFlOdnU eUkxwR1yKfpxabdRa2+qI0bzjz09SQDFlxcQp+XieKyBoFhiPS3Ro1eE5dakfx8ObOw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388600; 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=h30o4POnlBKYmB7h3RFvzLlup/rJieb58ojPnOhFgYI=; b=EkE/3ACfwFxI+RkEJ7y+4m+rAL+a6eHO9zOzaWLk/zsZmKAW/jYQEhInIdn4OT3RPl71 kwml8LQgwbRInefsr9JsaaR07DLdHDOWkW88aj04CCnOwKxW3GFDHJR7WozwYe1VSdB1r pVdhTscK2KX5Z0NtUGJNGggty0vH6+QBzXzk2vj0LsS1x7h1NjsIvjeJJjVnGGQIw9Mjp qhbX/0byFVRIX/v8PGWPJnqP34Z/+v+Z8H2HewIFHMPXsbhzFQ0i1shM4upGMTpG8SJjT o9zYTTa9OCuyNuJQ9OSIpsCdeSr4aNdBwFcQCAsFNOMW99hpagYFdGiKrWuDl92Pe5A== 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=S3+ks3BF; 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 5A21B606A322; Fri, 4 Dec 2026 12:50:00 +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=S3+ks3BF Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1FA91F000CE; Fri, 4 Dec 2026 12:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388600; bh=h30o4POnlBKYmB7h3RFvzLlup/rJieb58ojPnOhFgYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=S3+ks3BFRbkfLKLaeMfzBFrhLSo9N6sEFSIW7E7WayWcqhIHSUg7ZxqVtX6fphrur kwp1T2T4Lij99Dv0/xfuGfMBDJOTfeFHbcPZfIltmybWzGFs4Lf4m+eGxFud5EIlJR I8Xlzr5vsAkAzLSzzpZanSMfLNh4UAHHsAyOiTwM= 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.1 0683/1059] Bluetooth: btusb: fix use-after-free in force_poll_sync Date: Fri, 4 Dec 2026 19:03:34 +0900 Message-ID: <20261204100701.695796431@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: 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.1-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 9f91b7521a0e6..223b4477e7cdb 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -854,6 +854,8 @@ struct btusb_data { int (*setup_on_usb)(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; }; @@ -4260,8 +4262,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; @@ -4297,6 +4300,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