Re: [RFC PATCH] usb: hcd: warn about URB buffers that are not DMA aligned and are about to be DMA mapped

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

 



On 14.06.2013 23:20, Alan Stern wrote:
> On Fri, 14 Jun 2013, Jussi Kivilinna wrote:
> 
>> Appearently some out-of-tree USB host drivers do not handle DMA alignment for
>> URB buffers and let core/hcd.c to do the mapping on architectures that have
>> minimum DMA alignment requirements. This leads to random memory corruptions
>> and crashes when using USB device drivers that use unaligned URB buffers.
>>
>> Instead of fixing host drivers, users end up posting bug reports against
>> those USB device drivers that use unaligned buffers for URB; such as with
>> rtl8192cu (http://thread.gmane.org/gmane.linux.kernel.wireless.general/105631).
>>
>> Patch makes this issue more visible at core level, and hopefully gives hint
>> for future hcd driver implementors about this problem.
>>
>> Signed-off-by: Jussi Kivilinna <jussi.kivilinna@xxxxxx>
> 
> It's probably okay to leave out the test for the setup buffer.  That 
> thing is only 8 bytes long and is unlikely to be misaligned.  The 
> transfer buffer is the one that matters.

The rtl8192cu driver used to allocate the transfer buffer and the setup buffer with
same kmalloc, so that setup and transfer buffers for same URB shared cache-line.
This was causing pretty hard crashes with ARM/sunxi device I have. Before I realized
that problem really was in the host controller driver, I made patch to rtl8192cu
that changed code to use two separate kmallocs.

Old code looked like:
  http://lxr.linux.no/linux+v3.7/drivers/net/wireless/rtlwifi/usb.c#L58

> 
> Also, the error message should include the name of the host controller 
> driver.  How about using dev_WARN_ONCE(hcd->self.controller, ...)?

Ah, thanks, didn't know about dev_WARN*.

-Jussi

> 
> 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