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: <Pine.LNX.4.60.0704211251050.14499@poirot.grange>
Date:	Sat, 21 Apr 2007 13:01:14 +0200 (CEST)
From:	Guennadi Liakhovetski <g.liakhovetski@....de>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	James Bottomley <James.Bottomley@...elEye.com>,
	linux-kernel@...r.kernel.org, starvik@...s.com
Subject: Re: [PATCH] dma_declare_coherent_memory wrong allocation

On Sat, 21 Apr 2007, Andrew Morton wrote:

> On Fri, 13 Apr 2007 20:08:28 +0200 (CEST) Guennadi Liakhovetski <g.liakhovetski@....de> wrote:
> 
> > Hi
> > 
> > Either I've finally gone blind on this Friday 13th or... Looks like this 
> > almost 3 year old function has a bug. Patch below compile-tested... in a 
> > way.

[patch skipped]

> Looks that way to me, too.

Then I'll dare suggest arch/cris - the second and last arch implementing 
this API - has the same problem. Maintainer added to cc:, patch below.

> It also hopes like hell that `size' was a multiple of PAGE_SIZE.

Well, this API seems to have a bigger problem: it is difficult to get to 
SoC/bus-local memory from several child devices. Even if I do implement 
that DMA_MEMORY_INCLUDES_CHILDREN flag, 1) you do not always have the 
desired device as your immediate parent, 2) you have to ref-count it. For 
example, I was trying to use SoC-local SRAM on PXA270 from the 
framebuffer, but fb-devices on PXA are either platform devices, or 
sometimes get other parents. So, looks like another way to get to the SoC 
node is needed...

Thanks
Guennadi
---
Guennadi Liakhovetski

Fix dma_declare_coherent_memory wrong allocation for cris/arch-v32
    
arch/cris/arch-v32 seems to have copy-pasted the bug from arch/i386 fixed 
with an earlier patch - allocate bitmap in bytes, not words.
    
Signed-off-by: G. Liakhovetski <g.liakhovetski@....de>

diff --git a/arch/cris/arch-v32/drivers/pci/dma.c b/arch/cris/arch-v32/drivers/pci/dma.c
index 70d3bf0..d634347 100644
--- a/arch/cris/arch-v32/drivers/pci/dma.c
+++ b/arch/cris/arch-v32/drivers/pci/dma.c
@@ -76,7 +76,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 {
 	void __iomem *mem_base;
 	int pages = size >> PAGE_SHIFT;
-	int bitmap_size = (pages + 31)/32;
+	int bitmap_size = DIV_ROUND_UP(pages, 8);
 
 	if ((flags & (DMA_MEMORY_MAP | DMA_MEMORY_IO)) == 0)
 		goto out;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ