History

dma-mapping: Add vmap checks to dma_map_single()

As we've seen from USB and other areas[1], we need to always do runtime checks for DMA operating on memory regions that might be remapped. This adds vmap checks (similar to those already in USB but missing in other places) into dma_map_single() so all callers benefit from the checking. [1] https://git.kernel.org/linus/3840c5b78803b2b6cc1ff820100a74a092c40cbb

Kees Cook committed 7 years ago

Commit 4544b9f1 parent a445e941 file · +4 −0Browse files

Showing the changes to include/linux (1 of 1 file). Show all

Unified · Split

include/linux/dma-mapping.h+4−0
@@ -583,6 +583,10 @@ static inline unsigned long dma_get_merge_boundary(struct device *dev) · 582 unmodified lines
583583 static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
584584 size_t size, enum dma_data_direction dir, unsigned long attrs)
585585 {
586+ /* DMA must never operate on areas that might be remapped. */
587+ if (dev_WARN_ONCE(dev, is_vmalloc_addr(ptr),
588+ "rejecting DMA map of vmalloc memory\n"))
589+ return DMA_MAPPING_ERROR;
586590 debug_dma_map_single(dev, ptr, size);
587591 return dma_map_page_attrs(dev, virt_to_page(ptr), offset_in_page(ptr),
588592 size, dir, attrs);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t