From: yuehaibing@huawei.com (YueHaibing)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: dma-mapping: always clear allocated buffers
Date: Wed, 25 Jul 2018 15:07:06 +0800 [thread overview]
Message-ID: <20180725070706.19576-1-yuehaibing@huawei.com> (raw)
Sean Wang reported dma_zalloc_coherent doesn't work as expect on his
armv7,the allocated mem is not zeroed.The reason is __alloc_from_pool
doesn't honor __GFP_ZERO.
As commit 6829e274a623 ("arm64: dma-mapping: always clear allocated buffers")
has pointed out,buffers allocated by dma_alloc_coherent() are always zeroed
on most architectures. some drivers rely on this 'feature'. Allocated buffer
might be also exposed to userspace with dma_mmap() call,so clearing it is
desired from security point of view to avoid exposing random memory to userspace.
This patch unifies dma_alloc_coherent() behavior on ARM architecture with other
implementations by unconditionally zeroing allocated buffer.Also to fix
dma_zalloc_coherent behavior.
Reported-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: zhong jiang <zhongjiang@huawei.com>
---
v2: reference more argument from arm64 commit as Christoph suggested
---
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 6656647..cf5882f 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -564,6 +564,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
next reply other threads:[~2018-07-25 7:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-25 7:07 YueHaibing [this message]
2018-07-25 7:13 ` [PATCH v2] ARM: dma-mapping: always clear allocated buffers YueHaibing
2018-08-22 1:47 ` YueHaibing
2018-09-15 11:29 ` YueHaibing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180725070706.19576-1-yuehaibing@huawei.com \
--to=yuehaibing@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox