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=1796379768; b=yNHNyZXTnF4DMH2knBBSdvciFFiCUotyrELybOzpi9w2LEm7+2qNbjkekuTGyepBu/04 Cx1qiHFh4H5HzfUAqATqSCNe0LWFYhQZACZ2/9WNcIM4PqJpMJFKSb5zqTqFVBEmKvW4C 4Ga+uDVTsbOY37yZQtcP2bQ5Ta8lg39GtslBj2BJPoPyGRpTT+A84p1eZ6Xyr83ZCkFzq kt6vffxtJT5R8+duzi18qlocOaVlasr15RYFbPTAH4Fng9HxYsD+1aS+qkETYyuxd8hxr UhOHIPC2hORSd2B2QuBTPP/t2MtFkE1ATl2xp6OnCtp++FnUN2Shk91hdFbyk+ZCYDQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379768; 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=wPPrEYvSyjLHXeDvYsM0XZN1KaeiM+H+JlH/v0MXsaI=; b=nafSdcM3YQf/6rSgOm5lHkA7av/c2suCI64qfFp9RcdabVh5vrlaC9BMOzF1f17Uwkqp PPzjQnpR+WxSuWCqO1/w/lc9blKWg3wpfviNbRxCFV4NQpk1Nx8MA/cOiqTRJADLHwB4F OyIh5WWZL4R6/Sfg2kKRthzIV+apTHNxTVX9gqwLG9pVxNDVKRCw/88Q0Q1CklJiaPXVn lJR6aWmxEwPmCdFCyCodfQHCmXBzFtAM18EgfJ9LDmmnGLHclvLRtuM+pNQwJBEUc+2iC u1JXWicngVbiMABEasqeqKeR40TAHIlL5tAUWPW2OF+A6qHP0uYj6PfxscZc8R8nlcA== 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=No0e5zja; 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 502A4606A322; Fri, 4 Dec 2026 10:22:48 +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=No0e5zja Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0C321F000CE; Fri, 4 Dec 2026 10:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379768; bh=wPPrEYvSyjLHXeDvYsM0XZN1KaeiM+H+JlH/v0MXsaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=No0e5zjaIDtWulePXlxJr97v1od3RhTukFbRvq+9ixh46Cbm6+NG/nNHvjoyd1LrO AnpEFcyDsbYL+DS0YlzE5P8hYL1iC7u0m+VHNTx+mJD4Bnh5aan66rLk3mpRKliYzx 22H3Cp1n25yvH2vHU4RNHIJAjKt2Dg3q7bkwZLPo= 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.12 052/555] Bluetooth: btusb: fix use-after-free in force_poll_sync Date: Fri, 4 Dec 2026 19:01:35 +0900 Message-ID: <20261204100608.341680896@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 6142546c387ee..48ae89803c4fd 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -995,6 +995,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; @@ -4231,8 +4233,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; @@ -4268,6 +4271,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