Re: [PATCH] USB: prevent overlapping access by usb-storage and usbfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 14 Jan 2013, Sergei Shtylyov wrote:

> Serialize usb-storage operations with usbfs and 'cat /proc/bus/usb/devices',
> so that they cannot disturb storage by seemingly harmless control reads.
> 
> This patch was adapted from 2.4.28 patch by Pete Zaitcev -- which I even had to
> reconstruct as I have never found it in its final  form.  That patch dates back
> to 2004 and it unfortunately wasn't applied to 2.6 branch in the same form back
> then (it was applied in another form and then immediately reverted). Despite 8+
> years passing from that moment, the vendors didn't stop producing USB devices
> that require this patch. Two recent examples are SanDisk Cruzer Slice 8GB and
> Kingston DataTraveller 100 G2 32GB.  In the latter case, even the enumeration
> fails as the INQUIRY command takes 2.8 seconds to finish, so 'udev' also comes
> into action with its control requests, with neither completing normally.

Without commenting on the wisdom of this patch, there are a couple of 
places where the comments could be improved.

> --- usb.orig/drivers/usb/core/devices.c
> +++ usb/drivers/usb/core/devices.c
> @@ -423,21 +423,30 @@ static char *usb_dump_desc(char *start, 
>  	if (start > end)
>  		return start;
>  
> +	/*
> +	 * Grab device's exclusive_access mutex to prevent its driver or
> +	 * devio from using this device while we are accessing it.

s/devio/usbfs/

> --- usb.orig/drivers/usb/storage/transport.c
> +++ usb/drivers/usb/storage/transport.c
> @@ -601,9 +601,18 @@ void usb_stor_invoke_transport(struct sc
>  	int need_auto_sense;
>  	int result;
>  
> +	/*
> +	 * Grab device's exclusive_access mutex to prevent libusb/usbfs from
> +	 * sending out a command in the middle of ours (if libusb sends a
> +	 * get_descriptor or something on pipe 0 after our CBW and before

s/pipe 0/ep0/

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux