vhost: fix length for cross region descriptor
Subsystems (3)
Michael S. Tsirkin
maintainerPATCH 1/1 vhost: fix length for cross region descriptor
If a single descriptor crosses a region, the second chunk length should be decremented by size translated so far, instead it includes the full descriptor length.
Signed-off-by Michael S. Tsirkin <[email protected]>
--- drivers/vhost/vhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vhost/vhost.c +1 -1
@@ -1049,7 +1049,7 @@ static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len, } _iov = iov + ret; size = reg->memory_size - addr + reg->guest_phys_addr; - _iov->iov_len =min ((u64 )len, size); + _iov->iov_len =min ((u64 )len - s, size); _iov->iov_base = (void __user *)(unsigned long ) (reg->userspace_addr + addr - reg->guest_phys_addr); s += size;
Signature · 1 line
MST
Quoted 15 lines · Michael S. Tsirkin
If a single descriptor crosses a region, the second chunk length should be decremented by size translated so far, instead it includes the full descriptor length.
Signed-off-by Michael S. Tsirkin <[email protected]>--- drivers/vhost/vhost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/vhost/vhost.c +0
-0
drivers/vhost/vhost.c static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len, · line 1055
Quoted 8 lines
drivers/vhost/vhost.c +1
-1@@ -1049,7 +1049,7 @@ static int translate_desc(struct vhost_dev *dev, u64 addr, u32 len, } _iov = iov + ret; size = reg->memory_size - addr + reg->guest_phys_addr; - _iov->iov_len =min ((u64 )len, size); + _iov->iov_len =min ((u64 )len - s, size); _iov->iov_base = (void __user *)(unsigned long ) (reg->userspace_addr + addr - reg->guest_phys_addr); s += size;
Acked-by Jason Wang <[email protected]>
From: "Michael S. Tsirkin" <[email protected]>
Date: Mon, 26 Nov 2012 17:57:27 +0200
Quoted 6 lines
If a single descriptor crosses a region, the second chunk length should be decremented by size translated so far, instead it includes the full descriptor length.
Signed-off-by Michael S. Tsirkin <[email protected]>
Applied, thanks.