Skip to contentSkip to conversation

vhost: Fix host panic if ioctl called with wrong index

PATCH Applied Krishna Kumar 2 participants 2 messages May 25, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: Fix host panic if ioctl called with wrong index

From: Krishna Kumar <[email protected]>

Missed a boundary value check in vhost_set_vring. The host panics if idx == nvqs is used in ioctl commands in vhost_virtqueue_init.

---
 drivers/vhost/vhost.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
diff -ruNp org/drivers/vhost/vhost.c new/drivers/vhost/vhost.c
@@ -374,7 +374,7 @@ static long vhost_set_vring(struct vhost
 	r = get_user(idx, idxp);
 	if (r < 0)
 		return r;
-	if (idx > d->nvqs)
+	if (idx >= d->nvqs)
 		return -ENOBUFS;
 
 	vq = d->vqs + idx;
maintainer Applied
#1 lore raw
Quoted 6 lines · Krishna Kumar

From: Krishna Kumar <[email protected]>

Missed a boundary value check in vhost_set_vring. The host panics if idx == nvqs is used in ioctl commands in vhost_virtqueue_init.

Thanks, applied.

Quoted 16 lines
---
 drivers/vhost/vhost.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -ruNp org/drivers/vhost/vhost.c new/drivers/vhost/vhost.c

drivers/vhost/vhost.c +1 -1
@@ -374,7 +374,7 @@ static long vhost_set_vring(struct vhost
 	r = get_user(idx, idxp);
 	if (r < 0)
 		return r;
-	if (idx > d->nvqs)
+	if (idx >= d->nvqs)
 		return -ENOBUFS;
 
 	vq = d->vqs + idx;