mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nfc: pn533: add timeout to USB frame send completion wait
@ 2026-10-23  2:56 Zhao Feng
  2026-10-27  3:08 ` netdev-bot+sashiko
  2026-10-27  7:01 ` Zhao Feng
  0 siblings, 2 replies; 3+ messages in thread
From: Zhao Feng @ 2026-10-23  2:56 UTC (permalink / raw)
  To: netdev
  Cc: krzysztof.kozlowski, linux-kernel, syzbot+1c5368988052dc2d8201,
	Zhao Feng

pn533_usb_send_frame() waits indefinitely for the out URB to complete.
A malicious or malfunctioning device that never completes the transfer
blocks the caller in uninterruptible sleep forever -- e.g. during
device probe in the usb_hub_wq worker -- triggering hung task splats.

Bound the wait with a 1 second timeout.  On timeout, kill the URB and
fail with -ETIMEDOUT so that probing or the command in progress fails
gracefully instead of hanging the task.

Reported-by: syzbot+1c5368988052dc2d8201@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=1c5368988052dc2d8201
Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com>
---
 drivers/nfc/pn533/usb.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index 0b7e3b118d..c2633b5da8 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -30,6 +30,9 @@
 #define ACS_VENDOR_ID 0x072f
 #define ACR122U_PRODUCT_ID 0x2200
 
+/* How long to wait for the out URB to complete */
+#define PN533_USB_SEND_TIMEOUT_MS	1000
+
 static const struct usb_device_id pn533_usb_table[] = {
 	{ USB_DEVICE(PN533_VENDOR_ID, PN533_PRODUCT_ID),
 	  .driver_info = PN533_DEVICE_STD },
@@ -184,7 +187,12 @@ static int pn533_usb_send_frame(struct pn533 *dev,
 	if (rc)
 		return rc;
 
-	wait_for_completion(&arg.done);
+	if (!wait_for_completion_timeout(&arg.done,
+					 msecs_to_jiffies(PN533_USB_SEND_TIMEOUT_MS))) {
+		usb_kill_urb(phy->out_urb);
+		phy->out_urb->context = cntx;
+		return -ETIMEDOUT;
+	}
 	phy->out_urb->context = cntx;
 
 	if (dev->protocol_type == PN533_PROTO_REQ_RESP) {
-- 
2.39.2



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

end of thread, other threads:[~2026-10-27  7:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-23  2:56 [PATCH] nfc: pn533: add timeout to USB frame send completion wait Zhao Feng
2026-10-27  3:08 ` netdev-bot+sashiko
2026-10-27  7:01 ` Zhao Feng

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

all inboxes | Powered by JetHome®