]> xenbits.xensource.com Git - xen.git/commitdiff
x86/sysctl: don't clobber memory if NCAPINTS > ARRAY_SIZE(pi->hw_cap)
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 8 Oct 2015 10:43:18 +0000 (12:43 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 8 Oct 2015 10:43:18 +0000 (12:43 +0200)
There is no current problem, as both NCAPINTS and pi->hw_cap are 8 entries,
but the limit should be calculated appropriately so as to avoid hypervisor
stack corruption if the two do get out of sync.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: c373b912e74659f0e0898ae93e89513694cfd94e
master date: 2015-09-16 11:22:00 +0200

xen/arch/x86/sysctl.c

index 15d4b914e85a3d4eefb5c6efc07ceae610fe41b7..ee3b419adccbde969d00f8199e3ec3228aa83778 100644 (file)
@@ -59,7 +59,8 @@ long cpu_down_helper(void *data)
 
 void arch_do_physinfo(xen_sysctl_physinfo_t *pi)
 {
-    memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
+    memcpy(pi->hw_cap, boot_cpu_data.x86_capability,
+           min(sizeof(pi->hw_cap), sizeof(boot_cpu_data.x86_capability)));
     if ( hvm_enabled )
         pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm;
     if ( iommu_enabled )