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:   Fri, 13 Apr 2018 18:30:09 +0200
From:   jacopo mondi <jacopo@...ndi.org>
To:     Christoph Hellwig <hch@...radead.org>
Cc:     Jacopo Mondi <jacopo+renesas@...ndi.org>,
        laurent.pinchart@...asonboard.com, robin.murphy@....com,
        dalias@...c.org, ysato@...rs.sourceforge.jp,
        linux-sh@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-renesas-soc@...r.kernel.org, iommu@...ts.linux-foundation.org
Subject: Re: [PATCH] base: dma-mapping: Postpone cpu addr translation on
 mmap()

Hello again,

On Tue, Apr 10, 2018 at 09:57:52AM +0200, jacopo mondi wrote:
> Hi Christoph,
>
> On Mon, Apr 09, 2018 at 10:52:51AM -0700, Christoph Hellwig wrote:
> > On Mon, Apr 09, 2018 at 06:59:08PM +0200, Jacopo Mondi wrote:
> > > I'm still a bit puzzled on what happens if dma_mmap_from_dev_coherent() fails.
> > > Does a dma_mmap_from_dev_coherent() failure guarantee anyhow that the
> > > successive virt_to_page() isn't problematic as it is today?
> > > Or is it the
> > >  	if (off < count && user_count <= (count - off))
> > > check that makes the translation safe?
> >
> > It doesn't.  I think one major issue is that we should not simply fall
> > to dma_common_mmap if no method is required, but need every instance of
> > dma_map_ops to explicitly opt into an mmap method that is known to work.
>
> I see.. this patch thus just postpones the problem...
>
> >
> > >  #ifndef CONFIG_ARCH_NO_COHERENT_DMA_MMAP
> > >  	unsigned long user_count = vma_pages(vma);
> > >  	unsigned long count = PAGE_ALIGN(size) >> PAGE_SHIFT;
> > > -	unsigned long pfn = page_to_pfn(virt_to_page(cpu_addr));
> > >  	unsigned long off = vma->vm_pgoff;
> > > +	unsigned long pfn;
> > >
> > >  	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
> > >
> > > @@ -235,6 +235,7 @@ int dma_common_mmap(struct device *dev, struct vm_area_struct *vma,
> > >  		return ret;
> > >
> > >  	if (off < count && user_count <= (count - off)) {
> > > +		pfn = page_to_pfn(virt_to_page(cpu_addr));
> > >  		ret = remap_pfn_range(vma, vma->vm_start,
> > >  				      pfn + off,
> > >  				      user_count << PAGE_SHIFT,
> >
> > Why not:
> >
> > 		ret = remap_pfn_range(vma, vma->vm_start,
> > 				page_to_pfn(virt_to_page(cpu_addr)) + off,
> >
> > and save the temp variable?
>
> Sure, it's better... Should I send a v2 or considering your above
> comment this patch is just a mitigation and should be ditched in
> favour of a proper solution (which requires a much more considerable amount
> of work though)?

Don't want to be insistent, but I didn't get from your reply if a v2
is welcome or not :)

Thanks
  j

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ