Skip to contentSkip to conversation

xen/x86: domctl: Don't leak data via XEN_DOMCTL_gethvmcontext

PATCH In review Julien Grall 2 participants 2 messages Jan 27, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/x86: domctl: Don't leak data via XEN_DOMCTL_gethvmcontext

From: Julien Grall <[email protected]>

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.

---
 xen/arch/x86/domctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/domctl.c +1 -1
index 5ed63ac10a..4fa9c91140 100644
@@ -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:
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Julien Grall

From: Julien Grall <[email protected]>

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.

Quoted 6 lines

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.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel