Skip to contentSkip to conversation

usb: atm: use request_firmware_direct() for firmware probing

PATCH Applied Matvey Valigura 3 participants 3 messages Sep 24 – Sep 29

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: atm: use request_firmware_direct() for firmware probing

When disconnecting a device while firmware is not present on the system, usbatm_usb_disconnect() waits for the heavy_init thread to finish:

    wait_for_completion(&instance->thread_exited);

If CONFIG_FW_LOADER_USER_HELPER_FALLBACK is enabled, missing firmware causes request_firmware() to fall back to sysfs/udevd. This creates a circular dependency during disconnect:
1. usb_disconnect() holds device_lock(&udev->dev).
2. usbatm_usb_disconnect() waits for instance->thread to exit.
3. instance->thread waits for request_firmware() sysfs fallback.
4. udevd receives the firmware uevent and attempts to read sysfs attributes (e.g. serial), blocking on device_lock(&udev->dev).

Furthermore, the fallback wait uses wait_for_completion_killable_timeout(), which ignores the non-fatal SIGTERM signal sent by usbatm_usb_disconnect(). Because speedtch and cxacru probe multiple candidate firmware files sequentially, each file stalls for the 60-second fallback timeout, triggering hung task timeouts (>120s) reported by syzbot.

Switch to request_firmware_direct() to probe firmware files directly from the filesystem without falling back to user-mode helper.

---
 drivers/usb/atm/cxacru.c   | 2 +-
 drivers/usb/atm/speedtch.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/usb/atm/cxacru.c +1 -1
index 636f7886f..7d1944487 100644
@@ -993,7 +993,7 @@ static int cxacru_find_firmware(struct cxacru_data *instance,
 	sprintf(buf, "cxacru-%s.bin", phase);
 	usb_dbg(usbatm, "cxacru_find_firmware: looking for %s\n", buf);
 
-	if (request_firmware(fw_p, buf, dev)) {
+	if (request_firmware_direct(fw_p, buf, dev)) {
 		usb_dbg(usbatm, "no stage %s firmware found\n", phase);
 		return -ENOENT;
 	}
drivers/usb/atm/speedtch.c +3 -3
index 9d28c652b..c82db2f7a 100644
@@ -357,15 +357,15 @@ static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interfa
 	sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
 	usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
 
-	if (request_firmware(fw_p, buf, dev)) {
+	if (request_firmware_direct(fw_p, buf, dev)) {
 		sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
 		usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
 
-		if (request_firmware(fw_p, buf, dev)) {
+		if (request_firmware_direct(fw_p, buf, dev)) {
 			sprintf(buf, "speedtch-%d.bin", phase);
 			usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
 
-			if (request_firmware(fw_p, buf, dev)) {
+			if (request_firmware_direct(fw_p, buf, dev)) {
 				usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase);
 				return -ENOENT;
 			}
Signature · 1 line
2.55.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Matvey Valigura

When disconnecting a device while firmware is not present on the system, usbatm_usb_disconnect() waits for the heavy_init thread to finish:

    wait_for_completion(&instance->thread_exited);

If CONFIG_FW_LOADER_USER_HELPER_FALLBACK is enabled, missing firmware causes request_firmware() to fall back to sysfs/udevd. This creates a circular dependency during disconnect:
1. usb_disconnect() holds device_lock(&udev->dev).
2. usbatm_usb_disconnect() waits for instance->thread to exit.
3. instance->thread waits for request_firmware() sysfs fallback.
4. udevd receives the firmware uevent and attempts to read sysfs attributes (e.g. serial), blocking on device_lock(&udev->dev).

Furthermore, the fallback wait uses wait_for_completion_killable_timeout(), which ignores the non-fatal SIGTERM signal sent by usbatm_usb_disconnect(). Because speedtch and cxacru probe multiple candidate firmware files sequentially, each file stalls for the 60-second fallback timeout, triggering hung task timeouts (>120s) reported by syzbot.

Switch to request_firmware_direct() to probe firmware files directly from the filesystem without falling back to user-mode helper.

Quoted 4 lines
---
 drivers/usb/atm/cxacru.c   | 2 +-
 drivers/usb/atm/speedtch.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

I am assuming that in practice users do not load firmware for these devices from user-space.

#2 lore raw
In reply to Matvey Valigura
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 13 lines · On Thu, 24 Sep 2026 08:06:54 +0300 you wrote:

When disconnecting a device while firmware is not present on the system, usbatm_usb_disconnect() waits for the heavy_init thread to finish:

    wait_for_completion(&instance->thread_exited);

If CONFIG_FW_LOADER_USER_HELPER_FALLBACK is enabled, missing firmware causes request_firmware() to fall back to sysfs/udevd. This creates a circular dependency during disconnect:
1. usb_disconnect() holds device_lock(&udev->dev).
2. usbatm_usb_disconnect() waits for instance->thread to exit.
3. instance->thread waits for request_firmware() sysfs fallback.
4. udevd receives the firmware uevent and attempts to read sysfs attributes (e.g. serial), blocking on device_lock(&udev->dev).

Quoted 1 line

[...]

Here is the summary with links:
- usb: atm: use request_firmware_direct() for firmware probing

    https://git.kernel.org/netdev/net-next/c/f10883b37d9c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html