Skip to content

Commit 2699126

Browse files
Shuah Khangregkh
authored andcommitted
usbip: tools: usbipd: exclude exported devices from exportable device list
usbipd includes exported devices in response to exportable device list. Exclude exported devices from exportable device list to avoid: - import requests for devices that are exported only to fail the request. - revealing devices that are imported by a client to another client. Signed-off-by: Shuah Khan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1cbd53c commit 2699126

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tools/usb/usbip/src/usbipd.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,21 @@ static int send_reply_devlist(int connfd)
175175
struct list_head *j;
176176
int rc, i;
177177

178+
/*
179+
* Exclude devices that are already exported to a client from
180+
* the exportable device list to avoid:
181+
* - import requests for devices that are exported only to
182+
* fail the request.
183+
* - revealing devices that are imported by a client to
184+
* another client.
185+
*/
186+
178187
reply.ndev = 0;
179188
/* number of exported devices */
180189
list_for_each(j, &driver->edev_list) {
181-
reply.ndev += 1;
190+
edev = list_entry(j, struct usbip_exported_device, node);
191+
if (edev->status != SDEV_ST_USED)
192+
reply.ndev += 1;
182193
}
183194
info("exportable devices: %d", reply.ndev);
184195

@@ -197,6 +208,9 @@ static int send_reply_devlist(int connfd)
197208

198209
list_for_each(j, &driver->edev_list) {
199210
edev = list_entry(j, struct usbip_exported_device, node);
211+
if (edev->status == SDEV_ST_USED)
212+
continue;
213+
200214
dump_usb_device(&edev->udev);
201215
memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
202216
usbip_net_pack_usb_device(1, &pdu_udev);

0 commit comments

Comments
 (0)