|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 01/18] xen/pmstat: guard perf.states[] access with XEN_PX_INIT
Accessing to perf.states[] array shall not be only guarded with user-defined
hypercall input, so we add XEN_PX_INIT check to gain safety.
Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
---
v4 -> v5:
- new commit
---
xen/drivers/acpi/pmstat.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index c51b9ca358..b7fcc02db9 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -228,10 +228,13 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
ret = copy_to_guest(op->u.get_para.affected_cpus,
data, op->u.get_para.cpu_num);
- for ( i = 0; i < op->u.get_para.freq_num; i++ )
- data[i] = pmpt->perf.states[i].core_frequency * 1000;
- ret += copy_to_guest(op->u.get_para.scaling_available_frequencies,
- data, op->u.get_para.freq_num);
+ if ( pmpt->perf.init & XEN_PX_INIT )
+ {
+ for ( i = 0; i < op->u.get_para.freq_num; i++ )
+ data[i] = pmpt->perf.states[i].core_frequency * 1000;
+ ret += copy_to_guest(op->u.get_para.scaling_available_frequencies,
+ data, op->u.get_para.freq_num);
+ }
xfree(data);
if ( ret )
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |