# HG changeset patch # User Keir Fraser # Date 1222333937 -3600 # Node ID d4a093819310b70f24dfdc986755588ed5581a6e # Parent 50170dc8649cb43630f067eb9b2db3ce3f9c6db4 x86 pmstat: Fix get_pm_info hypercall argument checking. Signed-off-by: Lu Guanqun Signed-off-by: Keir Fraser --- a/xen/arch/x86/acpi/pmstat.c +++ b/xen/arch/x86/acpi/pmstat.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -53,14 +54,26 @@ int do_get_pm_info(struct xen_sysctl_get struct processor_pminfo *pmpt = &processor_pminfo[op->cpuid]; /* to protect the case when Px was not controlled by xen */ - if ( (!(pmpt->perf.init & XEN_PX_INIT)) && - (op->type & PMSTAT_CATEGORY_MASK) == PMSTAT_PX ) + if ( (op->cpuid >= NR_CPUS) || !cpu_online(op->cpuid) ) return -EINVAL; - if ( !cpu_online(op->cpuid) ) - return -EINVAL; + switch ( op->type & PMSTAT_CATEGORY_MASK ) + { + case PMSTAT_CX: + if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_CX) ) + return -ENODEV; + break; + case PMSTAT_PX: + if ( !(xen_processor_pmbits & XEN_PROCESSOR_PM_PX) ) + return -ENODEV; + if ( !(pmpt->perf.init & XEN_PX_INIT) ) + return -EINVAL; + break; + default: + return -ENODEV; + } - switch( op->type ) + switch ( op->type ) { case PMSTAT_get_max_px: {