lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 3 Aug 2017 17:57:50 +0200
From:   Johan Hovold <johan@...nel.org>
To:     Alan Stern <stern@...land.harvard.edu>
Cc:     Johan Hovold <johan@...nel.org>, Christoph Hellwig <hch@....de>,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Andreas Färber <afaerber@...e.de>,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-rpi-kernel@...ts.infradead.org,
        stable <stable@...r.kernel.org>,
        Robin Murphy <robin.murphy@....com>,
        Sricharan R <sricharan@...eaurora.org>,
        Stefan Wahren <stefan.wahren@...e.com>
Subject: Re: [PATCH v2] dma-mapping: skip USB devices when configuring DMA
 during probe

On Thu, Aug 03, 2017 at 04:49:24PM +0200, Johan Hovold wrote:
> On Thu, Aug 03, 2017 at 04:23:08PM +0200, Johan Hovold wrote:
> > On Thu, Aug 03, 2017 at 10:04:21AM -0400, Alan Stern wrote:
> > > On Thu, 3 Aug 2017, Johan Hovold wrote:
> > > 
> > > > USB devices use the DMA mask and offset of the controller, which have
> > > > already been setup when a device is probed. Note that modifying the
> > > > DMA mask of a USB device would change the mask for the controller (and
> > > > all devices on the bus) as the mask is literally shared.
> > > > 
> > > > Since commit 2bf698671205 ("USB: of: fix root-hub device-tree node
> > > > handling"), of_dma_configure() would be called also for root hubs, which
> > > > use the device node of the controller. A separate, long-standing bug
> > > > that makes of_dma_configure() generate a 30-bit DMA mask from the RPI3's
> > > > "dma-ranges" would thus set a broken mask also for the controller. This
> > > > in turn prevents USB devices from enumerating when control transfers
> > > > fail:
> > > > 
> > > > 	dwc2 3f980000.usb: Cannot do DMA to address 0x000000003a166a00
> > > > 
> > > > Note that the aforementioned DMA-mask bug was benign for the HCD itself
> > > > as the dwc2 driver overwrites the mask previously set by
> > > > of_dma_configure() for the platform device in its probe callback. The
> > > > mask would only later get corrupted when the root-hub child device was
> > > > probed.
> > > > 
> > > > Fix this, and similar future problems, by simply skipping USB devices
> > > > when dma_configure() is called during probe.
> > > > 
> > > > Fixes: 09515ef5ddad ("of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices")
> > > > Cc: stable <stable@...r.kernel.org>	# 4.12
> > > > Cc: Robin Murphy <robin.murphy@....com>
> > > > Cc: Sricharan R <sricharan@...eaurora.org>
> > > > Cc: Stefan Wahren <stefan.wahren@...e.com>
> > > > Reported-by: Hans Verkuil <hverkuil@...all.nl>
> > > > Signed-off-by: Johan Hovold <johan@...nel.org>
> > > > ---
> > 
> > > > diff --git a/include/linux/usb.h b/include/linux/usb.h
> > > > index cb9fbd54386e..f86ad9d8c756 100644
> > > > --- a/include/linux/usb.h
> > > > +++ b/include/linux/usb.h
> > > > @@ -1222,6 +1222,11 @@ struct usb_device_driver {
> > > >  
> > > >  extern struct bus_type usb_bus_type;
> > > >  
> > > > +static inline bool dev_is_usb(struct device *dev)
> > > > +{
> > > > +	return dev->bus == &usb_bus_type;
> > > > +}
> > > > +
> > > 
> > > Will this work if the USB subsystem is built as a module?
> > 
> > Nope. :-/
> > 
> > Add another flag (e.g. skip_dma_configure) to struct device for now?
> 
> Or we can make sure that of_dma_configure() is only ever called for
> platform_devices by checking against platform_bus_type instead.
> 
> I guess this was the intention of 09515ef5ddad ("of/acpi: Configure dma
> operations at probe time for platform/amba/pci bus devices") too.

Or perhaps not, as of_dma_configure() should also be called for pci
devices.

I suggest adding a new flag to struct device.

Johan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ