linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: dma-mapping: always clear allocated buffers in __alloc_from_pool
@ 2019-03-12  9:16 Yue Haibing
  2019-03-13 18:29 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Yue Haibing @ 2019-03-12  9:16 UTC (permalink / raw)
  To: linux, akpm, robin.murphy, iamjoonsoo.kim, hch
  Cc: YueHaibing, linux-kernel, linux-arm-kernel

From: YueHaibing <yuehaibing@huawei.com>

Like commit 518a2f1925c3 ("dma-mapping: zero memory returned
from dma_alloc_*"), if we want to map memory from the DMA
allocator to userspace it must be zeroed at allocation time 
to prevent stale data leaks. On arm platform, if the allocator
is pool_allocator in __dma_alloc, then the mem is alloced by
__alloc_from_pool, which also need be zeroed.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 arch/arm/mm/dma-mapping.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8a90f29..28ad6d5 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -558,6 +558,7 @@ static void *__alloc_from_pool(size_t size, struct page **ret_page)
 
 		*ret_page = phys_to_page(phys);
 		ptr = (void *)val;
+		memset(ptr, 0, size);
 	}
 
 	return ptr;
-- 
2.7.0



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: dma-mapping: always clear allocated buffers in __alloc_from_pool
  2019-03-12  9:16 [PATCH] ARM: dma-mapping: always clear allocated buffers in __alloc_from_pool Yue Haibing
@ 2019-03-13 18:29 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2019-03-13 18:29 UTC (permalink / raw)
  To: Yue Haibing
  Cc: linux, linux-kernel, hch, iamjoonsoo.kim, robin.murphy, akpm,
	linux-arm-kernel

On Tue, Mar 12, 2019 at 05:16:37PM +0800, Yue Haibing wrote:
> From: YueHaibing <yuehaibing@huawei.com>
> 
> Like commit 518a2f1925c3 ("dma-mapping: zero memory returned
> from dma_alloc_*"), if we want to map memory from the DMA
> allocator to userspace it must be zeroed at allocation time 
> to prevent stale data leaks. On arm platform, if the allocator
> is pool_allocator in __dma_alloc, then the mem is alloced by
> __alloc_from_pool, which also need be zeroed.

The observations looks correct, and because this memory is already
remapped I don't think we need __dma_clear_buffer here.

But I'd love to see a review from Russell as well.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-03-13 18:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12  9:16 [PATCH] ARM: dma-mapping: always clear allocated buffers in __alloc_from_pool Yue Haibing
2019-03-13 18:29 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).