diff options
author | Eric Dumazet <edumazet@google.com> | 2015-02-27 21:35:35 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-28 23:57:19 -0500 |
commit | 2f1d8b9e8afa5a833d96afcd23abcb8cdf8d83ab (patch) | |
tree | 12dbce95e244af612094c4cc7aa8e7ed0ab46755 /drivers/net/macvtap.c | |
parent | 32034e0580a9cd8cebd303ced20f54c06cb24f4d (diff) |
macvtap: make sure neighbour code can push ethernet header
Brian reported crashes using IPv6 traffic with macvtap/veth combo.
I tracked the crashes in neigh_hh_output()
-> memcpy(skb->data - HH_DATA_MOD, hh->hh_data, HH_DATA_MOD);
Neighbour code assumes headroom to push Ethernet header is
at least 16 bytes.
It appears macvtap has only 14 bytes available on arches
where NET_IP_ALIGN is 0 (like x86)
Effect is a corruption of 2 bytes right before skb->head,
and possible crashes if accessing non existing memory.
This fix should also increase IPv4 performance, as paranoid code
in ip_finish_output2() wont have to call skb_realloc_headroom()
Reported-by: Brian Rak <brak@vultr.com>
Tested-by: Brian Rak <brak@vultr.com>
Signed-off-by: Eric Dumazet <edumazet@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 | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c index e40fdfccc9c1..27ecc5c4fa26 100644 --- a/drivers/net/macvtap.c +++ b/drivers/net/macvtap.c | |||
@@ -654,11 +654,14 @@ static void macvtap_skb_to_vnet_hdr(struct macvtap_queue *q, | |||
654 | } /* else everything is zero */ | 654 | } /* else everything is zero */ |
655 | } | 655 | } |
656 | 656 | ||
657 | /* Neighbour code has some assumptions on HH_DATA_MOD alignment */ | ||
658 | #define MACVTAP_RESERVE HH_DATA_OFF(ETH_HLEN) | ||
659 | |||
657 | /* Get packet from user space buffer */ | 660 | /* Get packet from user space buffer */ |
658 | static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | 661 | static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, |
659 | struct iov_iter *from, int noblock) | 662 | struct iov_iter *from, int noblock) |
660 | { | 663 | { |
661 | int good_linear = SKB_MAX_HEAD(NET_IP_ALIGN); | 664 | int good_linear = SKB_MAX_HEAD(MACVTAP_RESERVE); |
662 | struct sk_buff *skb; | 665 | struct sk_buff *skb; |
663 | struct macvlan_dev *vlan; | 666 | struct macvlan_dev *vlan; |
664 | unsigned long total_len = iov_iter_count(from); | 667 | unsigned long total_len = iov_iter_count(from); |
@@ -722,7 +725,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m, | |||
722 | linear = macvtap16_to_cpu(q, vnet_hdr.hdr_len); | 725 | linear = macvtap16_to_cpu(q, vnet_hdr.hdr_len); |
723 | } | 726 | } |
724 | 727 | ||
725 | skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen, | 728 | skb = macvtap_alloc_skb(&q->sk, MACVTAP_RESERVE, copylen, |
726 | linear, noblock, &err); | 729 | linear, noblock, &err); |
727 | if (!skb) | 730 | if (!skb) |
728 | goto err; | 731 | goto err; |