tun: fix issues of iovec iterators using in tun_put_user()
Subsystems (3)
PATCH 1/1 tun: fix issues of iovec iterators using in tun_put_user()
This patch fixes two issues after using iovec iterators:
- vlan_offset should be initialized to zero, otherwise unexpected offset will be used in skb_copy_datagram_iter()
- advance iovec iterator when vnet_hdr_sz is greater than sizeof(gso), this is the case when mergeable rx buffer were enabled for a virt guest.
Fixes e0b46d0ee9c240c7430a47e9b0365674d4a04522 ("tun: Use iovec iterators")
--- drivers/net/tun.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/tun.c +3 -1
@@ -1235,7 +1235,7 @@ static ssize_t tun_put_user(struct tun_struct *tun, {struct tun_pi pi = {0 , skb->protocol };ssize_t total; -int vlan_offset; +int vlan_offset =0 ;int vlan_hlen =0 ;int vnet_hdr_sz =0 ;
@@ -1304,6 +1304,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,if (copy_to_iter (&gso,sizeof (gso), iter) !=sizeof (gso))return -EFAULT ; + +iov_iter_advance (iter, vnet_hdr_sz -sizeof (gso)); }if (vlan_hlen) {
Signature · 1 line
1.9.1
Quoted 9 lines · Jason Wang
This patch fixes two issues after using iovec iterators:
-vlan_offsetshould be initialized to zero, otherwise unexpected offset will be used inskb_copy_datagram_iter()
- advance iovec iterator whenvnet_hdr_szis greater than sizeof(gso), this is the case when mergeable rx buffer were enabled for a virt guest.Fixes
e0b46d0ee9c240c7430a47e9b0365674d4a04522("tun: Use iovec iterators")Cc Herbert Xu <[email protected]>Signed-off-by Jason Wang <[email protected]>
Good catch.
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
From: Herbert Xu <[email protected]>
Date: Thu, 13 Nov 2014 16:58:38 +0800
Quoted 7 lines · Jason Wang
Quoted 6 lines
This patch fixes two issues after using iovec iterators:
-vlan_offsetshould be initialized to zero, otherwise unexpected offset will be used inskb_copy_datagram_iter()
- advance iovec iterator whenvnet_hdr_szis greater than sizeof(gso), this is the case when mergeable rx buffer were enabled for a virt guest.
Quoted 7 lines
Quoted 3 lines
Fixes
e0b46d0ee9c240c7430a47e9b0365674d4a04522("tun: Use iovec iterators")Cc Herbert Xu <[email protected]>Signed-off-by Jason Wang <[email protected]>Good catch.
Acked-by Herbert Xu <[email protected]>
Applied, thanks everyone.