Skip to content

Commit 7b60a48

Browse files
committed
[efi] Clear DMA-coherent buffers before mapping
The DMA mapping is performed implicitly as part of the call to dma_alloc(). The current implementation creates the IOMMU mapping for the allocated and potentially uninitialised data before returning to the caller (which will immediately zero out or otherwise initialise the buffer). This leaves a small window within which a malicious PCI device could potentially attempt to retrieve firmware-owned secrets present in the uninitialised buffer. (Note that the hypothetically malicious PCI device has no viable way to know the address of the buffer from which to attempt a DMA read, rendering the attack extremely implausible.) Guard against any such hypothetical attacks by zeroing out the allocated buffer prior to creating the coherent DMA mapping. Suggested-by: Mateusz Siwiec <[email protected]> Signed-off-by: Michael Brown <[email protected]>
1 parent f48b01c commit 7b60a48

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/interface/efi/efi_pci.c

+3
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ static void * efipci_dma_alloc ( struct dma_device *dma,
524524
goto err_alloc;
525525
}
526526

527+
/* Clear buffer */
528+
memset ( addr, 0, ( pages * EFI_PAGE_SIZE ) );
529+
527530
/* Map buffer */
528531
if ( ( rc = efipci_dma_map ( dma, map, virt_to_phys ( addr ),
529532
( pages * EFI_PAGE_SIZE ),

0 commit comments

Comments
 (0)