tun: Fix GSO meta-data handling in tun_get_user
authorHerbert Xu <[email protected]>
Sun, 30 Nov 2014 10:03:31 +0000 (18:03 +0800)
committerDavid S. Miller <[email protected]>
Wed, 3 Dec 2014 04:53:47 +0000 (20:53 -0800)
When we write the GSO meta-data in tun_get_user we end up advancing
the IO vector twice, thus exhausting the user buffer before we can
finish writing the packet.

Fixes: f5ff53b4d97c ("{macvtap,tun}_get_user(): switch to iov_iter")
Reported-by: Marcelo Ricardo Leitner <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Acked-by: Jason Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/tun.c

index 4b743c612624ebfaf3fd9b7d66475a036cd2d8dd..6d44da1845945ba9400e5fba82f2d718a7a8a944 100644 (file)
@@ -1052,7 +1052,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 
                if (gso.hdr_len > len)
                        return -EINVAL;
-               iov_iter_advance(from, tun->vnet_hdr_sz);
+               iov_iter_advance(from, tun->vnet_hdr_sz - sizeof(gso));
        }
 
        if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {