linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-direct: zero out DMA_ATTR_NO_KERNEL_MAPPING buf
@ 2020-09-04 15:25 Hillf Danton
  2020-09-04 15:34 ` James Bottomley
  0 siblings, 1 reply; 8+ messages in thread
From: Hillf Danton @ 2020-09-04 15:25 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Hillf Danton, Kees Cook, linux-kernel, Matthew Wilcox,
	James Bottomley, linux-nvme, Marek Szyprowski


The DMA buffer allocated is always cleared in DMA core and this is
making DMA_ATTR_NO_KERNEL_MAPPING non-special.

Fixes: d98849aff879 ("dma-direct: handle DMA_ATTR_NO_KERNEL_MAPPING in common code")
Cc: Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
---

--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -178,9 +178,17 @@ void *dma_direct_alloc_pages(struct devi
 
 	if ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) &&
 	    !force_dma_unencrypted(dev)) {
+		int i;
+
 		/* remove any dirty cache lines on the kernel alias */
 		if (!PageHighMem(page))
 			arch_dma_prep_coherent(page, size);
+
+		for (i = 0; i < size/PAGE_SIZE; i++) {
+			ret = kmap_atomic(page + i);
+			memset(ret, 0, PAGE_SIZE);
+			kunmap_atomic(ret);
+		}
 		/* return the page pointer as the opaque cookie */
 		ret = page;
 		goto done;
--


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

end of thread, other threads:[~2020-09-07  7:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-04 15:25 [PATCH] dma-direct: zero out DMA_ATTR_NO_KERNEL_MAPPING buf Hillf Danton
2020-09-04 15:34 ` James Bottomley
2020-09-05  7:35   ` Hillf Danton
2020-09-05 15:46     ` James Bottomley
2020-09-05 15:50     ` James Bottomley
2020-09-06  1:09       ` Hillf Danton
2020-09-07  7:02       ` Marek Szyprowski
2020-09-07  7:49         ` 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).