lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250224013325.2928731-1-make24@iscas.ac.cn>
Date: Mon, 24 Feb 2025 09:33:25 +0800
From: Ma Ke <make24@...as.ac.cn>
To: gregkh@...uxfoundation.org,
	make24@...as.ac.cn,
	elder@...nel.org,
	quic_zijuhu@...cinc.com,
	kekrby@...il.com,
	oliver@...kum.org,
	stern@...land.harvard.edu
Cc: linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: [PATCH] USB: Skip resume if pm_runtime_set_active() fails

A race condition occurs during system suspend if interrupted between
usb_suspend() and the parent device’s PM suspend (e.g., a power
domain). This triggers PM resume workflows (via usb_resume()), but if
parent device is already runtime-suspended, pm_runtime_set_active()
fails. Subsequent operations like pm_runtime_enable() and interface
unbinding may leave the USB device in an inconsistent state or trigger
unintended behavior.

Found by code review.

Cc: stable@...r.kernel.org
Fixes: 98d9a82e5f75 ("USB: cleanup the handling of the PM complete call")
Signed-off-by: Ma Ke <make24@...as.ac.cn>
---
 drivers/usb/core/driver.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 460d4dde5994..7478fcc11fd4 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1624,11 +1624,17 @@ int usb_resume(struct device *dev, pm_message_t msg)
 	status = usb_resume_both(udev, msg);
 	if (status == 0) {
 		pm_runtime_disable(dev);
-		pm_runtime_set_active(dev);
+		status = pm_runtime_set_active(dev);
+		if (status) {
+			pm_runtime_enable(dev);
+			goto out;
+		}
+
 		pm_runtime_enable(dev);
 		unbind_marked_interfaces(udev);
 	}
 
+out:
 	/* Avoid PM error messages for devices disconnected while suspended
 	 * as we'll display regular disconnect messages just a bit later.
 	 */
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ