Sneak Into Your Thumb Drive from the Cloud

0
6959

Peripheral virtualisation

In the course of using a computer today, we connect devices like a thumb drive, printer, Web camera, etc, besides a mouse and keyboard, to a PC. But in a cloud computing set-up, when the computing service is in a remote location, how does an end user use such peripherals? In an ideal cloud set-up, these devices get virtually connected to a cloud server even though the device is connected to the client, which is at the user’s home set-up. These ideal cloud servers and home set-ups are available in Linux (and also other operating systems).

As a Linux hacker, you should be aware of what is happening inside the kernel driver layer that enables virtual peripheral connectivity. To understand this, let’s look at how to modify the Linux kernel and virtually connect USB devices to a cloud server. One important aspect to take care of during virtualisation is that timing requirements have to be satisfied as per the protocol specification, besides transparency to the user that it’s a virtual device. Thus, when virtualising a USB device, care has to be taken to ensure the quality of service and that the user doesn’t feel like the device is remotely connected.

To virtualise a USB device in a remote cloud server, ‘information’ that helps virtualise the device has to be made available over the IP network. The current driver design has to be modified to suit this requirement. To understand this, let us first analyse the USB driver architecture and then understand where to hook on this information to the IP layer.

A Linux USB host driver consists of three major layers. The first low-level module is the Host Controller Driver (HCD), which implements hardware specific routines. The next portion is the USB Core Driver implementing USB-specific functions. The final layer is the application layer. Figure 3 illustrates the USB driver architecture.

Figure 3: USB Linux software architecture in a normal setup
Figure 3: USB Linux software architecture in a normal setup

When our client desktop connects to a cloud server over the Internet, the device information and the data from the USB device has to be transferred through the network to a server on the remote cloud. This device information and data has to be tapped from the appropriate layer so that the virtual device can function properly. Figure 4 shows how the information could be tapped in a USB device.

Figure 4: Possible USB software architecture in a cloud setup
Figure 4: Possible USB software architecture in a cloud setup

USB virtualisation in your home lab

Having looked at all internal kernel changes, let us now explore how to set up a cloud-like environment in your home lab. To do the set-up, prepare two Linux machines and a USB peripheral like a thumb drive.

The open source ecosystem is rich with projects that allow us to explore multiple ideas and this applies to the current requirement too. The USB/IP project will help you to understand a possible approach of how a USB device can be virtualised across a network. The USB/IP ideally shares USB devices between computers by encapsulating USB transfers into TCP/IP payloads and transmits them between computers.

Here is a quick overview of how to set up a USP/IP at home. [For detailed steps, refer the README file or hack the source code.] In a USB/IP, the PC that exports a virtual device is referred to as a server and the PC that uses a virtual device, as the client.

The first step in the process is to download the source packages from usbip.sourceforge.net in both the computers. Compile the source in the driver folder and install the server drivers following the steps given in the README file.  Compile the USB/IP utils from the src/ directory and install the USB/IP daemon from the src/ folder as detailed in this README file. Follow the same process in the client PC as well.

After the successful installation of drivers, insert the thumb drive in the server PC. Go through the steps in this README file to export the thumb drive and access the client PC.

The USB/IP is an experimental project that was developed to extend the peripheral bus. Enthusiastic readers should refer to this URL to get more insights into the motivation behind the project and the achievements so far.

As new markets emerge with new technologies and different business models, traditional software architectures need to be looked at again. New innovative software architectures like USB/IP have to evolve to suit emerging technologies and business models, providing the user a better experience in terms of features and usability.

LEAVE A REPLY

Please enter your comment!
Please enter your name here