tun: read vnet_hdr_sz once
authorWillem de Bruijn <willemb@google.com>
Fri, 3 Feb 2017 23:20:48 +0000 (18:20 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Feb 2017 15:39:27 +0000 (16:39 +0100)
commit625bd9e43b3b6a5d796c6a5bac660dc405a60fa2
tree6ecb8b8717326a83d670ccfd71f94aab42de451d
parent82e9f6b90a0e7fbc017bdce23845c7580db6f657
tun: read vnet_hdr_sz once

[ Upstream commit e1edab87faf6ca30cd137e0795bc73aa9a9a22ec ]

When IFF_VNET_HDR is enabled, a virtio_net header must precede data.
Data length is verified to be greater than or equal to expected header
length tun->vnet_hdr_sz before copying.

Read this value once and cache locally, as it can be updated between
the test and use (TOCTOU).

Signed-off-by: Willem de Bruijn <willemb@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
CC: Eric Dumazet <edumazet@google.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/tun.c