diff options
author | Willem de Bruijn <willemb@google.com> | 2016-03-08 15:18:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-03-11 14:45:21 -0500 |
commit | 8e2ad4113ce4671686740f808ff2795395c39eef (patch) | |
tree | 864a6adc34ad064f7c9ffae05e15776078c4224e /drivers/net/macvtap.c | |
parent | 8208d21bf309551686b7a76d19059ae182a956d0 (diff) |
macvtap: always pass ethernet header in linear
The stack expects link layer headers in the skb linear section.
Macvtap can create skbs with llheader in frags in edge cases:
when (IFF_VNET_HDR is off or vnet_hdr.hdr_len < ETH_HLEN) and
prepad + len > PAGE_SIZE and vnet_hdr.flags has no or bad csum.
Add checks to ensure linear is always at least ETH_HLEN.
At this point, len is already ensured to be >= ETH_HLEN.
For backwards compatiblity, rounds up short vnet_hdr.hdr_len.
This differs from tap and packet, which return an error.
Fixes b9fb9ee07e67 ("macvtap: add GSO/csum offload support")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/macvtap.c')
-rw-r--r-- | drivers/net/macvtap.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index d636d051fac8..95394edd1ed5 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c | |||
@@ -760,6 +760,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
760 | macvtap16_to_cpu(q, vnet_hdr.hdr_len) : GOODCOPY_LEN; | 760 | macvtap16_to_cpu(q, vnet_hdr.hdr_len) : GOODCOPY_LEN; |
761 | if (copylen > good_linear) | 761 | if (copylen > good_linear) |
762 | copylen = good_linear; | 762 | copylen = good_linear; |
763 | else if (copylen < ETH_HLEN) | ||
764 | copylen = ETH_HLEN; | ||
763 | linear = copylen; | 765 | linear = copylen; |
764 | i = *from; | 766 | i = *from; |
765 | iov_iter_advance(&i, copylen); | 767 | iov_iter_advance(&i, copylen); |
@@ -769,10 +771,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
769 | 771 | ||
770 | if (!zerocopy) { | 772 | if (!zerocopy) { |
771 | copylen = len; | 773 | copylen = len; |
772 | if (macvtap16_to_cpu(q, vnet_hdr.hdr_len) > good_linear) | 774 | linear = macvtap16_to_cpu(q, vnet_hdr.hdr_len); |
775 | if (linear > good_linear) | ||
773 | linear = good_linear; | 776 | linear = good_linear; |
774 | else | 777 | else if (linear < ETH_HLEN) |
775 | linear = macvtap16_to_cpu(q, vnet_hdr.hdr_len); | 778 | linear = ETH_HLEN; |
776 | } | 779 | } |
777 | 780 | ||
778 | skb = macvtap_alloc_skb(&q->sk, MACVTAP_RESERVE, copylen, | 781 | skb = macvtap_alloc_skb(&q->sk, MACVTAP_RESERVE, copylen, |