xen/domctl: Fix Xen heap leak via XEN_DOMCTL_getvcpucontext
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sun, 8 Oct 2017 14:12:18 +0000 (15:12 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 9 Oct 2017 11:43:21 +0000 (12:43 +0100)
commit3b2eeb7412e529f38d1e8b872ba0bc6ab09a7008
tree968b78b25e567d522b51900dbd6a3d211e62891e
parente7ca8ad0014b8d21761440e502166f525f8951c1
xen/domctl: Fix Xen heap leak via XEN_DOMCTL_getvcpucontext

The backing structure for XEN_DOMCTL_getvcpucontext is only zeroed in the x86
HVM case.  At the very least, this means that ARM returns junk through its
flags field (as it is only ever conditionally or'd into), and x86 PV leaks
data through gdt_frames[14...15].  (An exhaustive search for other leaks
hasn't been performed).

Unconditionally zero the memory upon allocation, and forgo the double clear
for x86 HVM.  These hypercalls are not on hotpaths.

Note that this does not qualify for an XSA.  Per XSA-77,
XEN_DOMCTL_getvcpucontext is unsafe for disaggregation, meaning that only the
control domain can use this hypercall.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Julien Grall <julien.grall@linaro.org>
xen/arch/x86/domctl.c
xen/common/domctl.c