From: "Michael S. Tsirkin" <mst@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jason Wang <jasowang@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Neil Horman <nhorman@tuxdriver.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] tun: signedness bug in tun_get_user()
Date: Thu, 15 Aug 2013 14:58:40 +0000 [thread overview]
Message-ID: <20130815145840.GA8889@redhat.com> (raw)
In-Reply-To: <20130815140449.GA8064@redhat.com>
On Thu, Aug 15, 2013 at 05:04:49PM +0300, Michael S. Tsirkin wrote:
> On Thu, Aug 15, 2013 at 03:52:57PM +0300, Dan Carpenter wrote:
> > The recent fix d9bf5f1309 "tun: compare with 0 instead of total_len" is
> > not totally correct. Because "len" and "sizeof()" are size_t type, that
> > means they are never less than zero.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
Alternatively how about we revert the original patch?
This is not the only issue it introduced and it doesn't
actually fix any bugs.
> >
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index af987f0..7ed13cc 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -977,8 +977,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> > u32 rxhash;
> >
> > if (!(tun->flags & TUN_NO_PI)) {
> > - if ((len -= sizeof(pi)) < 0)
> > + if (len < sizeof(pi))
> > return -EINVAL;
> > + len -= sizeof(pi);
> >
> > if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
> > return -EFAULT;
> > @@ -986,8 +987,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> > }
> >
> > if (tun->flags & TUN_VNET_HDR) {
> > - if ((len -= tun->vnet_hdr_sz) < 0)
> > + if (len < tun->vnet_hdr_sz)
> > return -EINVAL;
> > + len -= tun->vnet_hdr_sz;
> >
> > if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
> > return -EFAULT;
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jason Wang <jasowang@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Neil Horman <nhorman@tuxdriver.com>,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] tun: signedness bug in tun_get_user()
Date: Thu, 15 Aug 2013 17:58:40 +0300 [thread overview]
Message-ID: <20130815145840.GA8889@redhat.com> (raw)
In-Reply-To: <20130815140449.GA8064@redhat.com>
On Thu, Aug 15, 2013 at 05:04:49PM +0300, Michael S. Tsirkin wrote:
> On Thu, Aug 15, 2013 at 03:52:57PM +0300, Dan Carpenter wrote:
> > The recent fix d9bf5f1309 "tun: compare with 0 instead of total_len" is
> > not totally correct. Because "len" and "sizeof()" are size_t type, that
> > means they are never less than zero.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Acked-by: Michael S. Tsirkin <mst@redhat.com>
Alternatively how about we revert the original patch?
This is not the only issue it introduced and it doesn't
actually fix any bugs.
> >
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index af987f0..7ed13cc 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -977,8 +977,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> > u32 rxhash;
> >
> > if (!(tun->flags & TUN_NO_PI)) {
> > - if ((len -= sizeof(pi)) < 0)
> > + if (len < sizeof(pi))
> > return -EINVAL;
> > + len -= sizeof(pi);
> >
> > if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
> > return -EFAULT;
> > @@ -986,8 +987,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> > }
> >
> > if (tun->flags & TUN_VNET_HDR) {
> > - if ((len -= tun->vnet_hdr_sz) < 0)
> > + if (len < tun->vnet_hdr_sz)
> > return -EINVAL;
> > + len -= tun->vnet_hdr_sz;
> >
> > if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
> > return -EFAULT;
next prev parent reply other threads:[~2013-08-15 14:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-15 12:52 [patch] tun: signedness bug in tun_get_user() Dan Carpenter
2013-08-15 12:52 ` Dan Carpenter
2013-08-15 14:04 ` Michael S. Tsirkin
2013-08-15 14:04 ` Michael S. Tsirkin
2013-08-15 14:58 ` Michael S. Tsirkin [this message]
2013-08-15 14:58 ` Michael S. Tsirkin
2013-08-15 15:02 ` Michael S. Tsirkin
2013-08-15 15:02 ` Michael S. Tsirkin
2013-08-15 15:05 ` Michael S. Tsirkin
2013-08-15 15:05 ` Michael S. Tsirkin
2013-08-15 20:08 ` Neil Horman
2013-08-15 20:08 ` Neil Horman
2013-08-15 21:51 ` David Miller
2013-08-15 21:51 ` David Miller
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=20130815145840.GA8889@redhat.com \
--to=mst@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.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.