Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2699126b authored by Shuah Khan's avatar Shuah Khan Committed by Greg Kroah-Hartman
Browse files

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: default avatarShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1cbd53c8
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -175,9 +175,20 @@ static int send_reply_devlist(int connfd)
	struct list_head *j;
	int rc, i;

	/*
	 * Exclude devices that are already exported to a client from
	 * the 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.
	 */

	reply.ndev = 0;
	/* number of exported devices */
	list_for_each(j, &driver->edev_list) {
		edev = list_entry(j, struct usbip_exported_device, node);
		if (edev->status != SDEV_ST_USED)
			reply.ndev += 1;
	}
	info("exportable devices: %d", reply.ndev);
@@ -197,6 +208,9 @@ static int send_reply_devlist(int connfd)

	list_for_each(j, &driver->edev_list) {
		edev = list_entry(j, struct usbip_exported_device, node);
		if (edev->status == SDEV_ST_USED)
			continue;

		dump_usb_device(&edev->udev);
		memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
		usbip_net_pack_usb_device(1, &pdu_udev);