macvtap: advance iov iterator when needed in macvtap_put_user()
Subsystems (2)
PATCH 1/1 macvtap: advance iov iterator when needed in macvtap_put_user()
When mergeable buffer is used, vnet_hdr_sz is greater than sizeof struct virtio_net_hdr. So we need advance the iov iterators in this case.
Fixes 6c36d2e26cda1ad3e2c4b90dd843825fc62fe5b4 ("macvtap: Use iovec iterators")
--- drivers/net/macvtap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/macvtap.c +2 -0
@@ -797,6 +797,8 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,if (copy_to_iter (&vnet_hdr,sizeof (vnet_hdr), iter) !=sizeof (vnet_hdr))return -EFAULT ; + +iov_iter_advance (iter, vnet_hdr_len -sizeof (vnet_hdr)); } total = vnet_hdr_len; total += skb->len;
Signature · 1 line
1.9.1
Quoted 6 lines · Jason Wang
When mergeable buffer is used,
vnet_hdr_szis greater than sizeof structvirtio_net_hdr. So we need advance the iov iterators in this case.Fixes
6c36d2e26cda1ad3e2c4b90dd843825fc62fe5b4("macvtap: Use iovec iterators")Cc Herbert Xu <[email protected]>Signed-off-by Jason Wang <[email protected]>
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 9 lines · Herbert Xu
Quoted 6 lines · Jason Wang
When mergeable buffer is used,
vnet_hdr_szis greater than sizeof structvirtio_net_hdr. So we need advance the iov iterators in this case.Fixes
6c36d2e26cda1ad3e2c4b90dd843825fc62fe5b4("macvtap: Use iovec iterators")Cc Herbert Xu <[email protected]>Signed-off-by Jason Wang <[email protected]>Acked-by Herbert Xu <[email protected]>
I'm not sure it's a good behaviour, actually - should we just leave an unmodified gap in userland buffer there, with whatever garbage it might have contained?
I do realize that this is what we used to do, but it might end up a source of hard to debug userland bugs... Perhaps that iov_iter_advance(iter, size) would better be replaced with iov_iter_zero(size, iter)?
Quoted 5 lines · Al Viro
Quoted 4 lines · Herbert Xu
Quoted 3 lines · Jason Wang
When mergeable buffer is used,
vnet_hdr_szis greater than sizeof structvirtio_net_hdr. So we need advance the iov iterators in this case.
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Fixes
6c36d2e26cda1ad3e2c4b90dd843825fc62fe5b4("macvtap: Use iovec iterators")Cc Herbert Xu <[email protected]>Signed-off-by Jason Wang <[email protected]>Acked-by Herbert Xu <[email protected]>I'm not sure it's a good behaviour, actually - should we just leave an unmodified gap in userland buffer there, with whatever garbage it might have contained?
Anyway it's the users(qemu or vhost_net) responsibility to fill the gap here.
Quoted 3 lines
I do realize that this is what we used to do, but it might end up a source of hard to debug userland bugs... Perhaps that
iov_iter_advance(iter, size)would better be replaced withiov_iter_zero(size, iter)?
Not sure, macvtap or tun behave like this in the past. It's easy to dump the header in guest for debugging. Zero the gap probably only help the case that the gap was forgot to be filled which looks rare.
From: Jason Wang <[email protected]>
Date: Thu, 20 Nov 2014 16:31:05 +0800
Quoted 6 lines
When mergeable buffer is used,
vnet_hdr_szis greater than sizeof structvirtio_net_hdr. So we need advance the iov iterators in this case.Fixes
6c36d2e26cda1ad3e2c4b90dd843825fc62fe5b4("macvtap: Use iovec iterators")Cc Herbert Xu <[email protected]>Signed-off-by Jason Wang <[email protected]>
Applied, thanks.