x86/sysctl: don't clobber memory if NCAPINTS > ARRAY_SIZE(pi->hw_cap)

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>
(cherry picked from commit c373b912e7)
This commit is contained in:
Andrew Cooper authored and Ian Campbell committed 2015-09-17 12:22:08 +01:00
1 parent 878d9320a8
commit 63e3edcc6c
1 file changed
+2 -1
+2 -1
View File
@@ -75,7 +75,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 )
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.