Skip to contentSkip to conversation

usb: usbip: stub_rx: remove outdated comment

PATCH In review Oliver Neukum 3 participants 3 messages Oct 5 – Oct 8

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

PATCH 1/1 usb: usbip: stub_rx: remove outdated comment

After removal of the BUG() statement the error exit can be reached and logs a report. Remove a comment saying otherwise.

Fixes 635f545a7e8be ("usbip: fix stub_rx: get_pipe() to validate endpoint number")
---
 drivers/usb/usbip/stub_rx.c | 1 -
 1 file changed, 1 deletion(-)
drivers/usb/usbip/stub_rx.c +0 -1
index 1e9ae578810d..0ccc05b76c5a 100644
@@ -391,7 +391,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
 	}
 
 err_ret:
-	/* NOT REACHED */
 	dev_err(&sdev->udev->dev, "CMD_SUBMIT: invalid epnum %d\n", epnum);
 	return -1;
 }
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] usbip: protocol desync and hung URBs on invalid endpoint --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usbip: protocol desync and hung URBs on invalid endpoint
--

commit f15a0a944a703fedd99ceab9d659df84a495556c
Author: Oliver Neukum <[email protected]>
Subject: usb: usbip: stub_rx: remove outdated comment

This patch removes an outdated comment in the error handling path of get_pipe(). The comment indicated the code was unreachable, but following the removal of a BUG() statement, this path can now be reached and logs a report.

drivers/usb/usbip/stub_rx.c static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu) · line 395

Quoted 11 lines
drivers/usb/usbip/stub_rx.c +0 -1
index 1e9ae578810d9..0ccc05b76c5ab 100644
@@ -391,7 +391,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
 	}
 
 err_ret:
-	/* NOT REACHED */
 	dev_err(&sdev->udev->dev, "CMD_SUBMIT: invalid epnum %d\n", epnum);
 	return -1;

[Severity: High]
When get_pipe() returns -1, does it cause a protocol desync regression in stub_recv_cmd_submit()?

If a USBIP client sends a CMD_SUBMIT with an invalid endpoint number or an out-of-bounds number of isoc packets, get_pipe() returns -1.

Looking at drivers/usb/usbip/stub_rx.c:stub_recv_cmd_submit():

	int pipe = get_pipe(sdev, pdu);
	...
	if (pipe == -1)
		return;

When get_pipe() returns -1, stub_recv_cmd_submit() returns early without consuming the TCP payload or issuing a connection teardown (e.g., via usbip_event_add(ud, SDEV_EVENT_ERROR_TCP)).

For OUT transfers with a payload, the unread bytes remain in the socket buffer. The next loop iteration reads this leftover payload as a USBIP header, desynchronizing the protocol stream and abruptly terminating the connection.

For IN transfers, no payload is left, but the server drops the request without sending a RET_SUBMIT response.

Does this cause the client's URB to hang indefinitely?

If the client later unlinks this hung URB, it seems the server replies with a RET_UNLINK status of 0 (success) because it never tracked the dropped URB.

Could this trick the client into completing the failed URB with a false success status, breaking the protocol state machine?

Quoted 1 line
drivers/usb/usbip/stub_rx.c +0 -0
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Oliver Neukum
Quoted 14 lines · Oliver Neukum

After removal of the BUG() statement the error exit can be reached and logs a report. Remove a comment saying otherwise.

Fixes 635f545a7e8be ("usbip: fix stub_rx: get_pipe() to validate endpoint number")
---
  drivers/usb/usbip/stub_rx.c | 1 -
  1 file changed, 1 deletion(-)
drivers/usb/usbip/stub_rx.c +0 -0
index 1e9ae578810d..0ccc05b76c5a 100644

drivers/usb/usbip/stub_rx.c static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu) · line 396

Quoted 7 lines
drivers/usb/usbip/stub_rx.c +0 -1
@@ -391,7 +391,6 @@ static int get_pipe(struct stub_device *sdev, struct usbip_header *pdu)
  	}
 
  err_ret:
-	/* NOT REACHED */
  	dev_err(&sdev->udev->dev, "CMD_SUBMIT: invalid epnum %d\n", epnum);
  	return -1;
  }

Looks good to me.

thanks,
-- Shuah