xen/x86: domctl: Don't leak data via XEN_DOMCTL_gethvmcontext
authorJulien Grall <jgrall@amazon.com>
Mon, 27 Jan 2020 13:34:12 +0000 (13:34 +0000)
committerJulien Grall <julien@xen.org>
Fri, 31 Jan 2020 18:51:38 +0000 (18:51 +0000)
The HVM context may not fill up the full buffer passed by the caller.
While we report corectly the size of the context, we will still be
copying back the full size of the buffer.

As the buffer is allocated through xmalloc(), we will be copying some
bits from the previous allocation.

Only copy back the part of the buffer used by the HVM context to prevent
any leak.

Note that per XSA-72, this is not a security issue.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domctl.c

index 5ed63ac10a78722cb3bf0903b8258a85b15064ec..4fa9c91140c269a931025c8905459b99a2354359 100644 (file)
@@ -540,7 +540,7 @@ long arch_do_domctl(
         domain_unpause(d);
 
         domctl->u.hvmcontext.size = c.cur;
-        if ( copy_to_guest(domctl->u.hvmcontext.buffer, c.data, c.size) != 0 )
+        if ( copy_to_guest(domctl->u.hvmcontext.buffer, c.data, c.cur) != 0 )
             ret = -EFAULT;
 
     gethvmcontext_out: