xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Jan Beulich <JBeulich@suse.com>, xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] linux-2.6.18/xenbus: fix overflow check in xenbus_dev_write()
Date: Wed, 17 Oct 2012 12:26:18 -0400	[thread overview]
Message-ID: <20121017162617.GA32178@phenom.dumpdata.com> (raw)
In-Reply-To: <1350392403.18058.116.camel@zakaz.uk.xensource.com>

On Tue, Oct 16, 2012 at 02:00:03PM +0100, Ian Campbell wrote:
> On Tue, 2012-10-16 at 13:18 +0100, Jan Beulich wrote:
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> 
> CC-ing Konrad since I think that modulo tweaking the path this ought to
> apply as is to upstream kernels.
> 
> > 
> > --- a/drivers/xen/xenbus/xenbus_dev.c
> > +++ b/drivers/xen/xenbus/xenbus_dev.c
> > @@ -239,7 +239,7 @@ static ssize_t xenbus_dev_write(struct f
> >  	if (!is_xenstored_ready())
> >  		return -ENODEV;
> >  
> > -	if ((len + u->len) > sizeof(u->u.buffer)) {
> > +	if (len > sizeof(u->u.buffer) - u->len) {
> >  		rc = -EINVAL;
> >  		goto out;
> >  	}
> > 
> > 
> > 

Like this:

diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 89f7625..ac72702 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -458,7 +458,7 @@ static ssize_t xenbus_file_write(struct file *filp,
 		goto out;
 
 	/* Can't write a xenbus message larger we can buffer */
-	if ((len + u->len) > sizeof(u->u.buffer)) {
+	if (len > sizeof(u->u.buffer) - u->len) {
 		/* On error, dump existing buffer */
 		u->len = 0;
 		rc = -EINVAL;

      reply	other threads:[~2012-10-17 16:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-16 12:18 [PATCH] linux-2.6.18/xenbus: fix overflow check in xenbus_dev_write() Jan Beulich
2012-10-16 13:00 ` Ian Campbell
2012-10-17 16:26   ` Konrad Rzeszutek Wilk [this message]

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=20121017162617.GA32178@phenom.dumpdata.com \
    --to=konrad.wilk@oracle.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xen.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).