]> xenbits.xensource.com Git - xen.git/commitdiff
xen/x86: domctl: Don't leak data via XEN_DOMCTL_gethvmcontext
authorJulien Grall <jgrall@amazon.com>
Thu, 5 Mar 2020 10:32:53 +0000 (11:32 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 5 Mar 2020 10:32:53 +0000 (11:32 +0100)
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>
master commit: 41d8869003e96d8b7250ad1d0246371d6929aca6
master date: 2020-01-31 18:51:38 +0000

xen/arch/x86/domctl.c

index 6aa42941b26e8229c0dad67b312dff1fa135c0c7..676b92203dd705abea8a058a282a92dfc57c0019 100644 (file)
@@ -601,7 +601,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: