[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] linux-2.6.18/xenbus: fix overflow check in xenbus_dev_write()



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@xxxxxxxxxx>
> > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
> 
> 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;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.