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] [day] [month] [year] [list]
Date:   Thu, 14 May 2020 16:39:13 +0200
From:   Christoph Hellwig <hch@....de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Christoph Hellwig <hch@....de>, linux-usb@...r.kernel.org,
        linux-kernel@...r.kernel.org, Hillf Danton <hdanton@...a.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Jeremy Linton <jeremy.linton@....com>,
        syzbot+353be47c9ce21b68b7ed@...kaller.appspotmail.com,
        stable <stable@...r.kernel.org>
Subject: Re: [PATCH] USB: usbfs: fix mmap dma mismatch

On Thu, May 14, 2020 at 02:09:44PM +0200, Greg Kroah-Hartman wrote:
> > > +		if (dma_mmap_coherent(hcd->self.sysdev, vma, mem, dma_handle,
> > > +				      size)) {
> > > +			dec_usb_memory_use_count(usbm, &usbm->vma_use_count);
> > > +			return -EAGAIN;
> > > +		}
> > 
> > What about a goto label to share the error handling path?
> 
> I thought about that, but that's a bit messier than the duplicated lines
> here :)

Actually the error handling looks weird, we can just use normal unwinding
here with an extra call to usb_free_coherent.  Also -EAGAIN is a strange
error to return in this case, as it is simply incorrect.  I think passing
through the errors from dma_mmap_coherent and remap_pfn_range would make
a lot more sense.

Last but not least I wonder if this is the right place to open code
the localmem and has_dma checks - from a layering POV it should be
a usb_mmap_coherent helper at the same level as usb_alloc_coherent.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ