Skip to content

Commit

Permalink
tun: fix issues of iovec iterators using in tun_put_user()
Browse files Browse the repository at this point in the history
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 e0b46d0 ("tun: Use iovec iterators")
Cc: Herbert Xu <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
Acked-by: Herbert Xu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
jasowang authored and davem330 committed Nov 13, 2014
1 parent 882288c commit 8c847d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 8c847d2

Please sign in to comment.