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 --- 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