From: Jason Wang <jasowang@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.osdl.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vhost-net: fix range checking in mrg bufs case
Date: Thu, 16 Sep 2010 02:12:45 -0400 (EDT) [thread overview]
Message-ID: <1191794336.2270351284617565643.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com> (raw)
In-Reply-To: <20100914131552.GA1937@redhat.com>
Tested-by: Jason Wang <jasowang@redhat.com>
----- "Michael S. Tsirkin" <mst@redhat.com> wrote:
> In mergeable buffer case, we use headcount, log_num
> and seg as indexes in same-size arrays, and
> we know that headcount <= seg and
> log_num equals either 0 or seg.
>
> Therefore, the right thing to do is range-check seg,
> not headcount as we do now: these will be different
> if guest chains s/g descriptors (this does not
> happen now, but we can not trust the guest).
>
> Long term, we should add BUG_ON checks to verify
> two other indexes are what we think they should be.
>
> Reported-by: Jason Wang <jasowang@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Dave, I'll queue this on my tree, no need to bother.
>
> drivers/vhost/net.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
> index 6400cd5..f095de6 100644
> --- a/drivers/vhost/net.c
> +++ b/drivers/vhost/net.c
> @@ -245,7 +245,7 @@ static int get_rx_bufs(struct vhost_virtqueue
> *vq,
> int r, nlogs = 0;
>
> while (datalen > 0) {
> - if (unlikely(headcount >= VHOST_NET_MAX_SG)) {
> + if (unlikely(seg >= VHOST_NET_MAX_SG)) {
> r = -ENOBUFS;
> goto err;
> }
> --
> 1.7.3.rc1.5.ge5969
> _______________________________________________
> Virtualization mailing list
> Virtualization@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2010-09-16 6:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-14 13:15 [PATCH] vhost-net: fix range checking in mrg bufs case Michael S. Tsirkin
2010-09-16 6:12 ` Jason Wang [this message]
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=1191794336.2270351284617565643.JavaMail.root@zmail05.collab.prod.int.phx2.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=virtualization@lists.osdl.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;
as well as URLs for NNTP newsgroup(s).