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]
Message-ID: <cc8dd3f3261c75db44ebe991212b2b501b95fe5f.camel@suse.de>
Date:   Thu, 31 Oct 2019 11:44:50 +0100
From:   Nicolas Saenz Julienne <nsaenzjulienne@...e.de>
To:     Christoph Hellwig <hch@...radead.org>
Cc:     rubini@...dd.com, linux-kernel@...r.kernel.org,
        Marek Szyprowski <m.szyprowski@...sung.com>,
        Robin Murphy <robin.murphy@....com>, helgaas@...nel.org,
        iommu@...ts.linux-foundation.org
Subject: Re: [PATCH v2 1/2] dma-direct: check for overflows on 32 bit DMA
 addresses

On Wed, 2019-10-30 at 14:41 -0700, Christoph Hellwig wrote:
> On Fri, Oct 18, 2019 at 01:00:43PM +0200, Nicolas Saenz Julienne wrote:
> > +#ifndef CONFIG_ARCH_DMA_ADDR_T_64BIT
> > +	/* Check if DMA address overflowed */
> > +	if (min(addr, addr + size - 1) <
> > +		__phys_to_dma(dev, (phys_addr_t)(min_low_pfn << PAGE_SHIFT)))
> > +		return false;
> > +#endif
> 
> Would be nice to use IS_ENABLED and PFN_PHYS here, and I also think we
> need to use phys_to_dma to take care of the encryption bit.  If you then
> also introduce an end variable we can make the whole thing actually look
> nice:
> 
> static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t
> size)
> {
> 	dma_addr_t end = addr + size - 1;
> 
>         if (!dev->dma_mask)
>                 return false;
> 
> 	if (!IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
> 	    min(addr, end) < phys_to_dma(dev, PFN_PHYS(min_low_pfn)))
> 		return false;
> 
>         return end <= min_not_zero(*dev->dma_mask, dev->bus_dma_mask);
> }
> 
> Otherwise this looks sensible to me.

Thanks, noted.


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ