From: Jason Wang <jasowang@redhat.com> To: mst@redhat.com, kvm@vger.kernel.org, virtio-dev@lists.oasis-open.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jason Wang <jasowang@redhat.com> Subject: [PATCH net] vhost_net: do not report a used len larger than receive buffer size Date: Wed, 12 Feb 2014 13:57:46 +0800 [thread overview] Message-ID: <1392184666-17616-1-git-send-email-jasowang@redhat.com> (raw) Currently, even if the packet were truncated by lower socket, we still report the packet size as the used len which may confuse guest driver. Fixes this by returning the size of guest receive buffer instead. Fixes 3a4d5c94e959359ece6d6b55045c3f046677f55c (vhost_net: a kernel-level virtio server) Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> --- drivers/vhost/net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 9a68409..06268a0 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -525,7 +525,8 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, ++headcount; seg += in; } - heads[headcount - 1].len += datalen; + if (likely(datalen < 0)) + heads[headcount - 1].len += datalen; *iovcount = seg; if (unlikely(log)) *log_num = nlogs; -- 1.8.3.2
WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com> To: mst@redhat.com, kvm@vger.kernel.org, virtio-dev@lists.oasis-open.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] vhost_net: do not report a used len larger than receive buffer size Date: Wed, 12 Feb 2014 13:57:46 +0800 [thread overview] Message-ID: <1392184666-17616-1-git-send-email-jasowang@redhat.com> (raw) Currently, even if the packet were truncated by lower socket, we still report the packet size as the used len which may confuse guest driver. Fixes this by returning the size of guest receive buffer instead. Fixes 3a4d5c94e959359ece6d6b55045c3f046677f55c (vhost_net: a kernel-level virtio server) Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> --- drivers/vhost/net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 9a68409..06268a0 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -525,7 +525,8 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, ++headcount; seg += in; } - heads[headcount - 1].len += datalen; + if (likely(datalen < 0)) + heads[headcount - 1].len += datalen; *iovcount = seg; if (unlikely(log)) *log_num = nlogs; -- 1.8.3.2
next reply other threads:[~2014-02-12 5:57 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-02-12 5:57 Jason Wang [this message] 2014-02-12 5:57 ` [PATCH net] vhost_net: do not report a used len larger than receive buffer size Jason Wang 2014-02-12 11:52 ` Michael S. Tsirkin 2014-02-12 11:52 ` 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=1392184666-17616-1-git-send-email-jasowang@redhat.com \ --to=jasowang@redhat.com \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mst@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=virtio-dev@lists.oasis-open.org \ --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: linkBe 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.