]> xenbits.xensource.com Git - people/liuw/xen.git/commit
x86/hvm/ioreq: fix page referencing
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 20 Nov 2018 13:57:05 +0000 (14:57 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Nov 2018 13:57:05 +0000 (14:57 +0100)
commitf6b6ae78679b363ff670a9c125077c436dabd608
treec288b951fe4ef8dd0182ae25ad16071933f0fcbd
parent937ef32565fa3a81fdb37b9dd5aa99a1b87afa75
x86/hvm/ioreq: fix page referencing

The code does not take a page reference in hvm_alloc_ioreq_mfn(), only a
type reference. This can lead to a situation where a malicious domain with
XSM_DM_PRIV can engineer a sequence as follows:

- create IOREQ server: no pages as yet.
- acquire resource: page allocated, total 0.
- decrease reservation: -1 ref, total -1.

This will cause Xen to hit a BUG_ON() in free_domheap_pages().

This patch fixes the issue by changing the call to get_page_type() in
hvm_alloc_ioreq_mfn() to a call to get_page_and_type(). This change
in turn requires an extra put_page() in hvm_free_ioreq_mfn() in the case
that _PGC_allocated is still set (i.e. a decrease reservation has not
occurred) to avoid the page being leaked.

This is part of XSA-276.

Reported-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/ioreq.c