All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Dan Carpenter <error27@gmail.com>
Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	"maintainer:X86 ARCHITECTURE..." <x86@kernel.org>,
	kernel-janitors@vger.kernel.org,
	"open list:XEN HYPERVISOR IN..."
	<virtualization@lists.linux-foundation.org>,
	"open list:XEN HYPERVISOR IN..." <xen-devel@lists.xensource.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [patch] xen: off by one errors in multicalls.c
Date: Fri, 03 Jun 2011 18:24:20 +0000	[thread overview]
Message-ID: <4DE926D4.9010009@goop.org> (raw)
In-Reply-To: <20110603044528.GD3661@shale.localdomain>

On 06/02/2011 09:45 PM, Dan Carpenter wrote:
> 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.

Yeah, looks like a correct fix.  Fortunately I don't think anything
currently hits that path in practice, though there are some pending
patches which will exercise it more.

Thanks,
    J

> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> This is a static checker patch and I haven't tested it.  Please
> review carefully.
>
> diff --git a/arch/x86/xen/multicalls.c b/arch/x86/xen/multicalls.c
> index 8bff7e7..1b2b73f 100644
> --- a/arch/x86/xen/multicalls.c
> +++ b/arch/x86/xen/multicalls.c
> @@ -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));
> @@ -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;
>  }
>  
> @@ -216,7 +216,7 @@ 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;
> @@ -224,14 +224,14 @@ struct multicall_space xen_mc_extend_args(unsigned long op, size_t size)
>  	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;
>  }
>  
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization
>


WARNING: multiple messages have this Message-ID (diff)
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Dan Carpenter <error27@gmail.com>
Cc: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	"maintainer:X86 ARCHITECTURE..." <x86@kernel.org>,
	kernel-janitors@vger.kernel.org,
	"open list:XEN HYPERVISOR IN..."
	<virtualization@lists.linux-foundation.org>,
	"open list:XEN HYPERVISOR IN..." <xen-devel@lists.xensource.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [patch] xen: off by one errors in multicalls.c
Date: Fri, 03 Jun 2011 11:24:20 -0700	[thread overview]
Message-ID: <4DE926D4.9010009@goop.org> (raw)
In-Reply-To: <20110603044528.GD3661@shale.localdomain>

On 06/02/2011 09:45 PM, Dan Carpenter wrote:
> 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.

Yeah, looks like a correct fix.  Fortunately I don't think anything
currently hits that path in practice, though there are some pending
patches which will exercise it more.

Thanks,
    J

> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> This is a static checker patch and I haven't tested it.  Please
> review carefully.
>
> diff --git a/arch/x86/xen/multicalls.c b/arch/x86/xen/multicalls.c
> index 8bff7e7..1b2b73f 100644
> --- a/arch/x86/xen/multicalls.c
> +++ b/arch/x86/xen/multicalls.c
> @@ -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));
> @@ -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;
>  }
>  
> @@ -216,7 +216,7 @@ 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;
> @@ -224,14 +224,14 @@ struct multicall_space xen_mc_extend_args(unsigned long op, size_t size)
>  	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;
>  }
>  
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization
>

  reply	other threads:[~2011-06-03 18:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03  4:45 [patch] xen: off by one errors in multicalls.c Dan Carpenter
2011-06-03  4:45 ` Dan Carpenter
2011-06-03 18:24 ` Jeremy Fitzhardinge [this message]
2011-06-03 18:24   ` Jeremy Fitzhardinge
2011-06-03 19:57   ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-06-03 19:57     ` Konrad Rzeszutek Wilk
2011-06-03 18:24 ` Jeremy Fitzhardinge
  -- strict thread matches above, loose matches on Subject: below --
2011-06-03  4:45 Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DE926D4.9010009@goop.org \
    --to=jeremy@goop.org \
    --cc=error27@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jeremy.fitzhardinge@citrix.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=konrad.wilk@oracle.com \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.