dma-kmsan-unpoison-dma-mappings.patch removed from -mm tree
The quilt patch titled
Subject: dma: kmsan: unpoison DMA mappings
has been removed from the -mm tree. Its filename was
dma-kmsan-unpoison-dma-mappings.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Alexander Potapenko <[email protected]>
Subject: dma: kmsan: unpoison DMA mappings
Date: Thu, 15 Sep 2022 17:03:55 +0200
KMSAN doesn't know about DMA memory writes performed by devices. We unpoison such memory when it's mapped to avoid false positive reports.
Signed-off-by Alexander Potapenko <[email protected]>
Cc Alexander Viro <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Andrey Konovalov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Christoph Lameter <[email protected]>
Cc David Rientjes <[email protected]>
Cc Dmitry Vyukov <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Biggers <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Herbert Xu <[email protected]>
Cc Ilya Leoshkevich <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Kees Cook <[email protected]>
Cc Marco Elver <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Michael S. Tsirkin <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vasily Gorbik <[email protected]>
Cc Vegard Nossum <[email protected]>
Cc Vlastimil Babka <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
include/linux/kmsan.h | 41 +++++++++++++++++++++++++++ kernel/dma/mapping.c | 10 ++++-- mm/kmsan/hooks.c | 59 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 3 deletions(-)
include/linux/kmsan.h renamed from include/linux/kmsan.h~dma-kmsan-unpoison-dma-mappings +41 -0
@@ -9,6 +9,7 @@#ifndef _LINUX_KMSAN_H#define _LINUX_KMSAN_H +#include <linux/dma-direction.h> #include <linux/gfp.h> #include <linux/kmsan-checks.h> #include <linux/types.h>
@@ -16,6 +17,7 @@struct page ;struct kmem_cache ;struct task_struct ; +struct scatterlist ;#ifdef CONFIG_KMSAN
@@ -172,6 +174,35 @@ void kmsan_ioremap_page_range(unsigned l*/ void kmsan_iounmap_page_range (unsigned long start,unsigned long end); +/** +* kmsan_handle_dma() - Handle a DMA data transfer. +* @page: first page of the buffer. +* @offset: offset of the buffer within the first page. +* @size: buffer size. +* @dir: one of possible dma_data_direction values. +* +* Depending on @direction, KMSAN: +* * checks the buffer, if it is copied to device; +* * initializes the buffer, if it is copied from device; +* * does both, if this is a DMA_BIDIRECTIONAL transfer. +*/ +void kmsan_handle_dma (struct page *page,size_t offset,size_t size, +enum dma_data_direction dir); + +/** +* kmsan_handle_dma_sg() - Handle a DMA transfer using scatterlist. +* @sg: scatterlist holding DMA buffers. +* @nents: number of scatterlist entries. +* @dir: one of possible dma_data_direction values. +* +* Depending on @direction, KMSAN: +* * checks the buffers in the scatterlist, if they are copied to device; +* * initializes the buffers, if they are copied from device; +* * does both, if this is a DMA_BIDIRECTIONAL transfer. +*/ +void kmsan_handle_dma_sg (struct scatterlist *sg,int nents, +enum dma_data_direction dir); +#else static inline void kmsan_init_shadow (void )
@@ -254,6 +285,16 @@ static inline void kmsan_iounmap_page_ra { } +static inline void kmsan_handle_dma (struct page *page,size_t offset, +size_t size,enum dma_data_direction dir) +{ +} + +static inline void kmsan_handle_dma_sg (struct scatterlist *sg,int nents, +enum dma_data_direction dir) +{ +} +#endif #endif /* _LINUX_KMSAN_H */
kernel/dma/mapping.c renamed from kernel/dma/mapping.c~dma-kmsan-unpoison-dma-mappings +7 -3
@@ -10,6 +10,7 @@#include <linux/dma-map-ops.h> #include <linux/export.h> #include <linux/gfp.h> +#include <linux/kmsan.h> #include <linux/of_device.h> #include <linux/slab.h> #include <linux/vmalloc.h>
@@ -156,6 +157,7 @@ dma_addr_t dma_map_page_attrs(struct dev addr =dma_direct_map_page (dev, page, offset, size, dir, attrs); else addr = ops->map_page (dev, page, offset, size, dir, attrs); +kmsan_handle_dma (page, offset, size, dir);debug_dma_map_page (dev, page, offset, size, dir, addr, attrs);return addr;
@@ -194,11 +196,13 @@ static int __dma_map_sg_attrs(struct develse ents = ops->map_sg (dev, sg, nents, dir, attrs); -if (ents >0 ) +if (ents >0 ) { +kmsan_handle_dma_sg (sg, nents, dir);debug_dma_map_sg (dev, sg, nents, ents, dir, attrs); -else if (WARN_ON_ONCE (ents != -EINVAL && ents != -ENOMEM && - ents != -EIO && ents != -EREMOTEIO )) + }else if (WARN_ON_ONCE (ents != -EINVAL && ents != -ENOMEM && + ents != -EIO && ents != -EREMOTEIO )) {return -EIO ; + }return ents; }
mm/kmsan/hooks.c renamed from mm/kmsan/hooks.c~dma-kmsan-unpoison-dma-mappings +59 -0
75 lines not on this page · raw message
_
Patches currently in -mm which might be from [email protected] are