]> xenbits.xensource.com Git - xen.git/commit
x86/pv: Track and flush non-coherent mappings of RAM
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 9 Jun 2022 13:52:11 +0000 (15:52 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 9 Jun 2022 13:52:11 +0000 (15:52 +0200)
commit82ba97ec6b24f3e92fd1749962154cedf2addc5d
tree3e7023affa2c546ec981ef029112d3a110923cb5
parent25c7adeefa7538d1f88bab1859ce77f8b46f229e
x86/pv: Track and flush non-coherent mappings of RAM

There are legitimate uses of WC mappings of RAM, e.g. for DMA buffers with
devices that make non-coherent writes.  The Linux sound subsystem makes
extensive use of this technique.

For such usecases, the guest's DMA buffer is mapped and consistently used as
WC, and Xen doesn't interact with the buffer.

However, a mischevious guest can use WC mappings to deliberately create
non-coherency between the cache and RAM, and use this to trick Xen into
validating a pagetable which isn't actually safe.

Allocate a new PGT_non_coherent to track the non-coherency of mappings.  Set
it whenever a non-coherent writeable mapping is created.  If the page is used
as anything other than PGT_writable_page, force a cache flush before
validation.  Also force a cache flush before the page is returned to the heap.

This is CVE-2022-26364, part of XSA-402.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: c1c9cae3a9633054b177c5de21ad7268162b2f2c
master date: 2022-06-09 14:23:37 +0200
xen/arch/x86/mm.c
xen/arch/x86/pv/grant_table.c
xen/include/asm-x86/mm.h