Re: [PATCH] usbip: Close all listening sockets in request workers
From: Shuah Khan
Date: Fri Nov 13 2026 - 16:42:02 EST
On 11/12/26 19:37, raoxu wrote:
Hi Shuah,
Thanks for the review.
I found this while reviewing the listening socket handling across fork() in
usbipd.c, and then reproduced the issue with the unmodified usbipd binary on
two UOS test machines.
Both machines have usbip 2.0+6.5.10-2 installed, with usbipd located at
/usr/sbin/usbipd. This package contains the original listener handling.
I used separate test ports to avoid interfering with the default USB/IP
service.
On 10.20.12.188, the reproduction steps were:
1. Start usbipd as root with both IPv4 and IPv6 listeners:
sudo /usr/sbin/usbipd -d -4 -6 -t 43241
2. From a client machine, establish an IPv4 TCP connection and keep it open
without sending a USB/IP request:
python3 -c 'import socket,time; s=socket.create_connection(("10.20.12.188",43241)); time.sleep(300)'
3. Terminate only the main usbipd process with SIGTERM, leaving the worker
running.
You removed all the context from the thread :(
In the following path in process_request(), child exits after
handling the pdu - all open fds get closed.
childpid = fork();
if (childpid == 0) {
close(listenfd);
recv_pdu(connfd);
exit(0);
}
How does the problem you are describing happen in the normal
use-case when a child exits after handling the request. If
it doesn't there is no need for this change you are proposing.
thanks,
-- Shuah