netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost-net: fix range checking in mrg bufs case
@ 2010-09-14 13:15 Michael S. Tsirkin
  2010-09-16  6:12 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2010-09-14 13:15 UTC (permalink / raw)
  To: Michael S. Tsirkin, kvm, virtualization, netdev, linux-kernel

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-16  6:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).