Article View: linux.kernel.netdev
Article #26319[PATCH v5 07/33] USB: Release interface claims according to binding state
From: Leon Romanovsky
Date: Thu, 03 Dec 2026 12:03
Date: Thu, 03 Dec 2026 12:03
81 lines
10668 bytes
10668 bytes
From: Leon Romanovsky <leonro@nvidia.com>
A driver such as CDC-ACM can claim a sibling interface before it is
registered. Disabling USB bus autoprobing between the claim and
registration leaves dev->driver set without adding the interface to the
driver's bound-device list.
Releasing that interface through driver core then attempts to remove an
unattached list node, causing a NULL pointer dereference.
Fixes: b8c5cec23d5c ("Driver core: udev triggered device-<>driver binding")
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/usb/core/driver.c | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 735ae3310b45..d902708416d0 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -612,6 +612,15 @@ int usb_driver_claim_interface(struct usb_driver *driver,
}
EXPORT_SYMBOL_GPL(usb_driver_claim_interface);
+static void usb_unbind_claim(struct usb_interface *iface)
+{
+ struct device *dev = &iface->dev;
+
+ usb_unbind_interface(dev);
+ dev_set_drvdata(dev, NULL);
+ dev->driver = NULL;
+}
+
/**
* usb_driver_release_interface - unbind a driver from an interface
* @driver: the driver to be unbound
@@ -631,27 +640,25 @@ void usb_driver_release_interface(struct usb_driver *driver,
{
struct device *dev = &iface->dev;
- /* this should never happen, don't release something that's not ours */
- if (!dev->driver || dev->driver != &driver->driver)
- return;
-
- /* don't release from within disconnect() */
+ /* Avoid recursive locking from disconnect(). */
if (iface->condition != USB_INTERFACE_BOUND)
return;
+
+ device_lock(dev);
+ if (!dev->driver || dev->driver != &driver->driver ||
+ iface->condition != USB_INTERFACE_BOUND)
+ goto unlock;
iface->condition = USB_INTERFACE_UNBINDING;
- /* Release via the driver core only if the interface
- * has already been registered
- */
- if (device_is_registered(dev)) {
- device_release_driver(dev);
- } else {
- device_lock(dev);
- usb_unbind_interface(dev);
- dev_set_drvdata(dev, NULL);
- dev->driver = NULL;
+ if (device_is_bound(dev)) {
device_unlock(dev);
+ device_release_driver(dev);
+ return;
}
+
+ usb_unbind_claim(iface);
+unlock:
+ device_unlock(dev);
}
EXPORT_SYMBOL_GPL(usb_driver_release_interface);
--
2.56.1
Technical Details
Message-ID:
<20261203-device-trust-core-v5-7-485cc6eddd46@nvidia.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376541-linux-kernel-netdev=dewy.ruReferences:
<20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376541-linux-kernel-netdev=dewy.ru From: leon@kernel.org (Leon Romanovsky) Newsgroups: linux.kernel.netdev Subject: [PATCH v5 07/33] USB: Release interface claims according to binding state Date: Thu, 3 Dec 2026 14:03:29 +0200 Organization: Usenet Network Message-ID: <20261203-device-trust-core-v5-7-485cc6eddd46@nvidia.com> References: <20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2479949"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Prt8yUA8diF94fSjAF5IbijhBQI= sha256:De5v/IsKv0ABkDtk/3fZQczw1Ps/vPi/IGyzK2luIJ8= sha1:XbwRd4TOkm3gTZu571CfO+5ZQzU= sha256:UimZHN+eM8q3ra8Udr2cw9SZJVP/LazrP17qQqSk22o= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B1219117906; Thu, 3 Dec 2026 15:05:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.64 X-Spam-Status: No, score=-2.64 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PyR64fIfNheZ; Thu, 3 Dec 2026 15:05:27 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376541-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 4808F117904; Thu, 3 Dec 2026 15:05:19 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 6017B291D1; Thu, 3 Dec 2026 12:04:51 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796299463; b=NH27earR9zjTck3Y4mTrCU8PC05a1VB8hOTNY+TnCE3UPrQcVocYj4FfZpeJxuOdqgJO d9bJP3Spfad+hjNUPgMzJdHaYr2NnKdZojCVtw/BMNrtraLb3K4N43bmLbyK7vLGAYdV5 T6U21D25PVoefi4xaHSkILD72CkriFIV4FsobM6+jbO47bA5cFqTxLE41VSGxbyF/xxy6 h6oDKtvsoZP12Cv96ps1lyT3TBc6zfpNGmxBjPtXi0i60NDwAwJz9bnX2yKxPRSrbztog XouZVIpGjW7IvhiN69Kn6mx2a+/fcFwTghBXpjoScOv+oR7Tx2EQfNHJ67HlV06Ai4Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299463; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Type:X-Mailer: Content-Transfer-Encoding; bh=zYRk0Z3JkJjCV1+3rineSGYAuWTBHCz4IyiPSmBw3aE=; b=3ZxSopEOW12oCYCgFSXE66gGNoe4r+Hhvya0FnP8xJt/Obd7o20/QmcYsDbDDmivt0to LGtrzmirctQfBLbzoec7yEMyx3Tm6FUPPHSkOnPHXt57S7wy8G9TKEyEvfoyoE6uf2QQo LMhrD3JRPxXEF6P1JXl9OUF1buW8YOl+Y04bS67WwJTo6S4cIBjRQ4MTeyOU9TIas5gWV 309epLQmeZBXVj4uUCkmPSh59X76vlaoT6mlKDhx93ZbeIqMGXM5cvkKuxGhAD9taWoBs h00kz6Ro8YQFX9B320f4roVP26ek2LptUIYs8uN4qB8tO5FfV9IMd6fhLTphzpH2XkA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZfDM73up; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2344560A5BDC; Thu, 3 Dec 2026 12:04:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZfDM73up X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796299462; b=vMHIXAtYIQQLwTgDEwMHyOyuNaw0rkWbDUCDXdo8Yj0Zxv3HQ399fvxidQpt3Fbv/H0u w5P4sQm/uuf1rDWx3A3jOKqO0buSQMgk6RzUrk+2XzYrbgub6P/Fy2d2pLqV/it89f3U6 TkUVifpD4kPQoY7kGTDB0gZn27MI2Hd0FT/+1DNppv8V/L8BvZFW174bluZxm7xZIan4X 5MkouY13/9sZ6eDNON08gPkw427r5ZEhb5FtT0ks7Pxwr1ChDMeG696SaW+Ooe4M7xP6L xgca5ogO8x8QX7ex3Q8AKGhu3DdzdoKvgURe2T+30GvSJBgaRM4xjwfOKKS3m4rP4bA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796299462; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: Content-Transfer-Encoding; bh=zYRk0Z3JkJjCV1+3rineSGYAuWTBHCz4IyiPSmBw3aE=; b=SSsvAhJGPcEg/9EuJVhOrdhSBDtbqAWuuuX1q1VjwcIVLDNqhHhKy66hf3K5VG2bGr1/ QBuinJvvvYVzaEEVRmu8af13YEqne9ccYogZhBCAN3tpvbtzkoklXjeA0SuFAYrK0nLf1 RA+YgMAdpDwi+G4VwJcGG1FJA06rzctYBkWJccFdvw8+TGKiCcqkEN0UVqWok4TnSPhfU yl02GwS/kV3+mgV05xz1YD5AEwp93bAtPG/rSubGSnRpCx48lT5TXg1/a5xX1SWACCm2J qJFjtIdEsI5Q9kFXhyCiJ0HQNw+tKHPDVP6o/NIctUVq1ncDKXs99Vb8z5iBy2rutZQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZfDM73up; arc=none smtp.remote-ip=100.103.45.18 X-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 3E008606A685; Thu, 3 Dec 2026 12:04:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25E0A1F00899; Thu, 3 Dec 2026 12:04:21 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796299461; bh=zYRk0Z3JkJjCV1+3rineSGYAuWTBHCz4IyiPSmBw3aE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZfDM73upp0pZrPZy3etTvMbccqVDUbQC8iYUtZmkEXfWyIuRYulQXLfv6FqA2ouDb /4mQxDqG/BFTAxR8TTWiXdG3Mjgu5YfMx6hRb9W9X/4jtpNlfMN1KknF9rIlsQxz10 YP0jLDo4ldaRWOpndxDC/TgQuPvN8TKHu7Ed1nXLXoS2ANqwhHuYDkLzhBY6n8/pIs vJfVHa2Jw9sUbrLoR9RQjAgbphkYcMRGR12dZEGLlwvX06LIQNOPqERGRZEWbKw1NT mJC8Ln1afBlBOf0A9KbnYcMDUCmP8pFHMd93GJDOldIU6+VWc0s/hb2O5CAA49JsNA FMBgF0M2qohoQ== X-Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, linux-input@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-usb@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-acpi@vger.kernel.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux.dev, linux-coco@lists.linux.dev, Alexey Kardashevskiy <aik@amd.com>, Luiz Augusto von Dentz <luiz.von.dentz@intel.com>, Greg Kroah-Hartman <gregkh@suse.de>, linux-sound@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca> X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261203-device-trust-core-v5-0-485cc6eddd46@nvidia.com> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Mailer: b4 0.17-dev-d2b70