From: "Michael S. Tsirkin" <mst@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: Amit Shah <amit.shah@redhat.com>,
alex.williamson@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] virtio-net: correct header length math
Date: Wed, 23 Jun 2010 18:55:27 +0300 [thread overview]
Message-ID: <20100623155526.GE30526@redhat.com> (raw)
In-Reply-To: <m3eifxrbc6.fsf@trasno.mitica>
On Wed, Jun 23, 2010 at 05:57:13PM +0200, Juan Quintela wrote:
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > We were requesting too much when checking buffer
> > length: size already includes host header length.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> All changes here are ok, but we are still missing more checks.
>
> > ---
> > hw/virtio-net.c | 20 +++++++++++---------
> > 1 files changed, 11 insertions(+), 9 deletions(-)
> >
> > diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> > index 06ba481..2646c87 100644
> > --- a/hw/virtio-net.c
> > +++ b/hw/virtio-net.c
> > @@ -527,17 +527,18 @@ static ssize_t virtio_net_receive(VLANClientState *nc, const uint8_t *buf, size_
> > {
> > VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque;
> > struct virtio_net_hdr_mrg_rxbuf *mhdr = NULL;
> > - size_t hdr_len, offset, i;
> > + size_t guest_hdr_len, offset, i, host_hdr_len;
> >
> > if (!virtio_net_can_receive(&n->nic->nc))
> > return -1;
> >
> > /* hdr_len refers to the header we supply to the guest */
> > - hdr_len = n->mergeable_rx_bufs ?
> > + guest_hdr_len = n->mergeable_rx_bufs ?
> > sizeof(struct virtio_net_hdr_mrg_rxbuf) : sizeof(struct virtio_net_hdr);
> >
> >
>
> nitpit: empty extra line
>
> > - if (!virtio_net_has_buffers(n, size + hdr_len))
> > + host_hdr_len = n->has_vnet_hdr ? sizeof(struct virtio_net_hdr) : 0;
> > + if (!virtio_net_has_buffers(n, size + guest_hdr_len - host_hdr_len))
> > return 0;
> >
> > if (!receive_filter(n, buf, size))
>
> size is not used by receive_filter. We are assuming that size is at
> least 16 + sizeof(struct virtio_net_hdr).
True, I guess receive_filter should be fixed.
>
> while (offset < size) {
>
> we are still testing offset with size, but we read headers from there
> also :(
>From where? As far as I can tell we always read size bytes from buf. No?
> Later, Juan.
next prev parent reply other threads:[~2010-06-23 16:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-23 9:51 [Qemu-devel] [PATCH] virtio-net: correct header length math Michael S. Tsirkin
2010-06-23 15:57 ` [Qemu-devel] " Juan Quintela
2010-06-23 15:55 ` Michael S. Tsirkin [this message]
2010-06-24 8:42 ` Amit Shah
2010-06-24 8:39 ` Michael S. Tsirkin
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=20100623155526.GE30526@redhat.com \
--to=mst@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=amit.shah@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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.