Skip to content

Commit

Permalink
xen: off by one errors in multicalls.c
Browse files Browse the repository at this point in the history
b->args[] has MC_ARGS elements, so the comparison here should be
">=" instead of ">".  Otherwise we read past the end of the array
one space.

CC: stable@kernel.org
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
  • Loading branch information
Dan Carpenter authored and Konrad Rzeszutek Wilk committed Jun 3, 2011
1 parent e5ac0bd commit f124c6a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions arch/x86/xen/multicalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ struct multicall_space __xen_mc_entry(size_t args)
unsigned argidx = roundup(b->argidx, sizeof(u64));

BUG_ON(preemptible());
BUG_ON(b->argidx > MC_ARGS);
BUG_ON(b->argidx >= MC_ARGS);

if (b->mcidx == MC_BATCH ||
(argidx + args) > MC_ARGS) {
(argidx + args) >= MC_ARGS) {
mc_stats_flush(b->mcidx == MC_BATCH ? FL_SLOTS : FL_ARGS);
xen_mc_flush();
argidx = roundup(b->argidx, sizeof(u64));
Expand All @@ -206,7 +206,7 @@ struct multicall_space __xen_mc_entry(size_t args)
ret.args = &b->args[argidx];
b->argidx = argidx + args;

BUG_ON(b->argidx > MC_ARGS);
BUG_ON(b->argidx >= MC_ARGS);
return ret;
}

Expand All @@ -216,22 +216,22 @@ struct multicall_space xen_mc_extend_args(unsigned long op, size_t size)
struct multicall_space ret = { NULL, NULL };

BUG_ON(preemptible());
BUG_ON(b->argidx > MC_ARGS);
BUG_ON(b->argidx >= MC_ARGS);

if (b->mcidx == 0)
return ret;

if (b->entries[b->mcidx - 1].op != op)
return ret;

if ((b->argidx + size) > MC_ARGS)
if ((b->argidx + size) >= MC_ARGS)
return ret;

ret.mc = &b->entries[b->mcidx - 1];
ret.args = &b->args[b->argidx];
b->argidx += size;

BUG_ON(b->argidx > MC_ARGS);
BUG_ON(b->argidx >= MC_ARGS);
return ret;
}

Expand Down

0 comments on commit f124c6a

Please sign in to comment.