public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATH v2] usb: usblp: add the reset_resume function interface
@ 2026-03-17 12:56 shitao
  2026-03-17 13:28 ` Greg KH
  2026-03-17 14:06 ` Alan Stern
  0 siblings, 2 replies; 6+ messages in thread
From: shitao @ 2026-03-17 12:56 UTC (permalink / raw)
  To: zaitcev, gregkh; +Cc: linux-usb, shitao

Add reset_resume callback to prevent premature device unbinding during
S4 (hibernation) thaw phase, which would otherwise cause usblp to require
a re-probe — a process that is slow and trigger error -517, and even
has a high probability of causing use-after-free bugs and kernel panics.

Problem:
When a USB printer(CH340S USB-to-parallel adapter ID 1a86:7584)
is connected during S4 hibernation,the following sequence occurs:

1. During thaw phase, USB core sets udev->reset_resume = 1
2. usb_resume_interface() checks for driver->reset_resume callback
3. If not implemented, interface is marked as needs_binding=1
4. usb_resume() calls unbind_marked_interfaces()
5. This forces disconnect via usb_forced_unbind_intf()
6. usblp_disconnect() immediately frees usblp structure if !usblp->used
7. However, PM subsystem still has references (usage_count > 0)
8. Subsequent PM callbacks access freed memory (0x6b6b6b6b SLAB poison)
9. Result: kernel panic in pm_op() with use-after-free

The bug manifests as:
Unable to handle kernel paging request at virtual address 006b6b6b6b6b6b93
pc : pm_op+0x50/0x80
Call trace:
pm_op+0x50/0x80
dpm_resume+0xdc/0x200
hibernation_snapshot+0x234/0x3d8

Signed-off-by: shitao <shitao@kylinos.cn>
---
 drivers/usb/class/usblp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 669b9e6879bf..d0e286fe7108 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1473,6 +1473,7 @@ static struct usb_driver usblp_driver = {
 	.disconnect =	usblp_disconnect,
 	.suspend =	usblp_suspend,
 	.resume =	usblp_resume,
+	.reset_resume =	usblp_resume,
 	.id_table =	usblp_ids,
 	.dev_groups =	usblp_groups,
 	.supports_autosuspend =	1,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-17 16:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-17 12:56 [PATH v2] usb: usblp: add the reset_resume function interface shitao
2026-03-17 13:28 ` Greg KH
2026-03-17 14:14   ` Oliver Neukum
2026-03-17 14:06 ` Alan Stern
2026-03-17 14:35   ` Oliver Neukum
2026-03-17 16:38     ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox