All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* swiotlb/virtio: unchecked device dma address and length
@ 2020-12-11 17:31 Felicitas Hetzelt
  2020-12-14 21:49   ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 27+ messages in thread
From: Felicitas Hetzelt @ 2020-12-11 17:31 UTC (permalink / raw)
  To: virtualization, iommu
  Cc: Radev, Martin, david.kaplan, Michael S. Tsirkin, Jason Wang,
	konrad.wilk, Robert Buhren, Morbitzer, Mathias

Hello,
we have been analyzing the Hypervisor-OS interface of Linux
and discovered bugs in the swiotlb/virtio implementation that can be
triggered from a malicious Hypervisor / virtual device.
With SEV, the SWIOTLB implementation is forcefully enabled and would
always be used. Thus, all virtio devices and others would use it under
the hood.

The reason for analyzing this interface is that, technologies such as
Intel's Trusted Domain Extensions [1] and AMD's Secure Nested Paging [2]
change the threat model assumed by various Linux kernel subsystems.
These technologies take the presence of a fully malicious hypervisor
into account and aim to provide protection for virtual machines in such
an environment. Therefore, all input received from the hypervisor or an
external device should be carefully validated. Note that these issues
are of little (or no) relevance in a "normal" virtualization setup,
nevertheless we believe that it is required to fix them if TDX or SNP is
used.

We are happy to provide more information if needed!

[1]
https://software.intel.com/content/www/us/en/develop/articles/intel-trust-domain-extensions.html

[2] https://www.amd.com/en/processors/amd-secure-encrypted-virtualization

Bug:
OOB memory write.
dma_unmap_single -> swiotlb_tbl_unmap_single is invoked with dma_addr
and length parameters that are under control of the device.
This happens e.g. in virtio_ring:
https://elixir.bootlin.com/linux/v5.10-rc7/source/drivers/virtio/virtio_ring.c#L378

This raises two issues:
1) swiotlb_tlb_unmap_single fails to check whether the index generated
from the dma_addr is in range of the io_tlb_orig_addr array.
2) when swiotlb_bounce is called the device controls the length of the
memory copied to the cpu address.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, other threads:[~2020-12-18  9:29 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 17:31 swiotlb/virtio: unchecked device dma address and length Felicitas Hetzelt
2020-12-14 21:49 ` Konrad Rzeszutek Wilk
2020-12-14 21:49   ` Konrad Rzeszutek Wilk
2020-12-15  3:20   ` Jason Wang
2020-12-15  3:20     ` Jason Wang
2020-12-15 14:27     ` Konrad Rzeszutek Wilk
2020-12-15 14:27       ` Konrad Rzeszutek Wilk
2020-12-16  5:53       ` Jason Wang
2020-12-16  5:53         ` Jason Wang
2020-12-16  6:41         ` Jason Wang
2020-12-16  6:41           ` Jason Wang
2020-12-16 13:04           ` Konrad Rzeszutek Wilk
2020-12-16 13:04             ` Konrad Rzeszutek Wilk
2020-12-17  4:19             ` Jason Wang
2020-12-17  4:19               ` Jason Wang
2020-12-17 22:55               ` Ashish Kalra
2020-12-16  8:54     ` Michael S. Tsirkin
2020-12-16  8:54       ` Michael S. Tsirkin
2020-12-16 13:07       ` Konrad Rzeszutek Wilk
2020-12-16 13:07         ` Konrad Rzeszutek Wilk
2020-12-16 22:07         ` Radev, Martin
2020-12-17 23:17           ` Ashish Kalra
2020-12-18  9:28             ` Radev, Martin
2020-12-15  8:47   ` Ashish Kalra
2020-12-15 10:54     ` Felicitas Hetzelt
2020-12-15 14:37       ` Konrad Rzeszutek Wilk
2020-12-15 14:37         ` Konrad Rzeszutek Wilk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.