public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: virtualization@lists.linux-foundation.org
Subject: potential integer overflow in xenbus_file_write()
Date: Thu, 13 Sep 2012 19:00:32 +0300	[thread overview]
Message-ID: <20120913160032.GA29082@elgon.mountain> (raw)

Hi,

I was reading some code and had a question in xenbus_file_write()

drivers/xen/xenbus/xenbus_dev_frontend.c
   461          if ((len + u->len) > sizeof(u->u.buffer)) {
                     ^^^^^^^^^^^^
Can this addition overflow?  Should the test be something like:

	if (len > sizeof(u->u.buffer) || len + u->len > sizeof(u->u.buffer)) {

   462                  /* On error, dump existing buffer */
   463                  u->len = 0;
   464                  rc = -EINVAL;
   465                  goto out;
   466          }
   467  
   468          ret = copy_from_user(u->u.buffer + u->len, ubuf, len);
   469  

regards,
dan carpenter

             reply	other threads:[~2012-09-13 16:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 16:00 Dan Carpenter [this message]
2012-10-15 10:25 ` potential integer overflow in xenbus_file_write() Ian Campbell
     [not found] ` <1350296757.18058.21.camel@zakaz.uk.xensource.com>
2012-10-16  8:54   ` [Xen-devel] " Jan Beulich

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=20120913160032.GA29082@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=virtualization@lists.linux-foundation.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