lkml.org 
[lkml]   [2019]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v4 3/9] swiotlb: Zero out bounce buffer for untrusted device
    Date
    This is necessary to avoid exposing valid kernel data to any
    milicious device.

    Suggested-by: Christoph Hellwig <hch@lst.de>
    Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
    ---
    kernel/dma/swiotlb.c | 6 ++++++
    1 file changed, 6 insertions(+)

    diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
    index f956f785645a..ed41eb7f6131 100644
    --- a/kernel/dma/swiotlb.c
    +++ b/kernel/dma/swiotlb.c
    @@ -35,6 +35,7 @@
    #include <linux/scatterlist.h>
    #include <linux/mem_encrypt.h>
    #include <linux/set_memory.h>
    +#include <linux/pci.h>
    #ifdef CONFIG_DEBUG_FS
    #include <linux/debugfs.h>
    #endif
    @@ -560,6 +561,11 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
    */
    for (i = 0; i < nslots; i++)
    io_tlb_orig_addr[index+i] = orig_addr + (i << IO_TLB_SHIFT);
    +
    + /* Zero out the bounce buffer if the consumer is untrusted. */
    + if (dev_is_untrusted(hwdev))
    + memset(phys_to_virt(tlb_addr), 0, alloc_size);
    +
    if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
    (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
    swiotlb_bounce(orig_addr, tlb_addr, mapping_size, DMA_TO_DEVICE);
    --
    2.17.1
    \
     
     \ /
      Last update: 2019-06-03 03:23    [W:4.107 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site