|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 6/8] tools/xenalyze: Fix off-by-one in MAX_CPUS range checks
Skip action / throw error if cpu/vcpu >= MAX_CPUS rather than >.
Also add an assertion to vcpu_find, to make future errors of this kind
not out-of-bounds.
CID 1306871
CID 1306870
CID 1306869
CID 1306867
Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
CC: Ian Jackson <ian.jackson@xxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
---
tools/xentrace/xenalyze.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c
index 249bebd..3e26a4c 100644
--- a/tools/xentrace/xenalyze.c
+++ b/tools/xentrace/xenalyze.c
@@ -6860,6 +6860,13 @@ struct vcpu_data * vcpu_find(int did, int vid)
struct domain_data *d;
struct vcpu_data *v;
+ /* "Graceful" handling of vid >= MAX_CPUS should be handled elsewhere */
+ if ( vid >= MAX_CPUS ) {
+ fprintf(stderr, "%s: vcpu %d exceeds MAX_CPUS %d!\n",
+ __func__, vid, MAX_CPUS);
+ error(ERR_ASSERT, NULL);
+ }
+
d = domain_find(did);
v = d->vcpu[vid];
@@ -7131,7 +7138,7 @@ void sched_runstate_process(struct pcpu_info *p)
}
}
- if(r->vcpu > MAX_CPUS)
+ if(r->vcpu >= MAX_CPUS)
{
fprintf(warn, "%s: vcpu %u > MAX_VCPUS %d!\n",
__func__, r->vcpu, MAX_CPUS);
@@ -7441,14 +7448,14 @@ void sched_switch_process(struct pcpu_info *p)
r->prev_dom, r->prev_vcpu,
r->next_dom, r->next_vcpu);
- if(r->prev_vcpu > MAX_CPUS)
+ if(r->prev_vcpu >= MAX_CPUS)
{
fprintf(warn, "%s: prev_vcpu %u > MAX_VCPUS %d!\n",
__func__, r->prev_vcpu, MAX_CPUS);
return;
}
- if(r->next_vcpu > MAX_CPUS)
+ if(r->next_vcpu >= MAX_CPUS)
{
fprintf(warn, "%s: next_vcpu %u > MAX_VCPUS %d!\n",
__func__, r->next_vcpu, MAX_CPUS);
@@ -8518,7 +8525,7 @@ off_t scan_for_new_pcpu(off_t offset) {
cd = (typeof(cd))rec.u.notsc.data;
- if ( cd->cpu > MAX_CPUS )
+ if ( cd->cpu >= MAX_CPUS )
{
fprintf(stderr, "%s: cpu %d exceeds MAX_CPU %d!\n",
__func__, cd->cpu, MAX_CPUS);
@@ -8738,7 +8745,7 @@ void process_cpu_change(struct pcpu_info *p) {
(unsigned long long)p->file_offset);
}
- if(r->cpu > MAX_CPUS)
+ if(r->cpu >= MAX_CPUS)
{
fprintf(stderr, "FATAL: cpu %d > MAX_CPUS %d.\n",
r->cpu, MAX_CPUS);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |