Skip to content

Commit e2aaa2c

Browse files
edumazetsashalevin
authored andcommitted
macvtap: make sure neighbour code can push ethernet header
[ Upstream commit 2f1d8b9 ] 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> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 7c03ec3 commit e2aaa2c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎drivers/net/macvtap.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,15 @@ static void macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
637637
} /* else everything is zero */
638638
}
639639

640+
/* Neighbour code has some assumptions on HH_DATA_MOD alignment */
641+
#define MACVTAP_RESERVE HH_DATA_OFF(ETH_HLEN)
642+
640643
/* Get packet from user space buffer */
641644
static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
642645
const struct iovec *iv, unsigned long total_len,
643646
size_t count, int noblock)
644647
{
645-
int good_linear = SKB_MAX_HEAD(NET_IP_ALIGN);
648+
int good_linear = SKB_MAX_HEAD(MACVTAP_RESERVE);
646649
struct sk_buff *skb;
647650
struct macvlan_dev *vlan;
648651
unsigned long len = total_len;
@@ -701,7 +704,7 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
701704
linear = vnet_hdr.hdr_len;
702705
}
703706

704-
skb = macvtap_alloc_skb(&q->sk, NET_IP_ALIGN, copylen,
707+
skb = macvtap_alloc_skb(&q->sk, MACVTAP_RESERVE, copylen,
705708
linear, noblock, &err);
706709
if (!skb)
707710
goto err;

0 commit comments

Comments
 (0)