]> git.baikalelectronics.ru Git - kernel.git/commit
swiotlb: Validate bounce size in the sync/unmap path
authorMartin Radev <martin.b.radev@gmail.com>
Tue, 12 Jan 2021 15:07:29 +0000 (16:07 +0100)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 26 Feb 2021 15:52:51 +0000 (10:52 -0500)
commitffb93b1d5683a595da059da7026f64f399c90981
tree72852211acfff1c57280b9865afdd0a625f7381c
parent51b8098c61817266c4fc99c7d9f4f8f893f7381b
swiotlb: Validate bounce size in the sync/unmap path

The size of the buffer being bounced is not checked if it happens
to be larger than the size of the mapped buffer. Because the size
can be controlled by a device, as it's the case with virtio devices,
this can lead to memory corruption.

This patch saves the remaining buffer memory for each slab and uses
that information for validation in the sync/unmap paths before
swiotlb_bounce is called.

Validating this argument is important under the threat models of
AMD SEV-SNP and Intel TDX, where the HV is considered untrusted.

Signed-off-by: Martin Radev <martin.b.radev@gmail.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
kernel/dma/swiotlb.c