diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-06-29 21:24:21 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-06-29 21:24:21 +0200 |
commit | 6e2c1a4057f48f023a31dd08ed43eb9940859952 (patch) | |
tree | ee6217f3c6099d3ecae35616a4619ff63da75f40 /src | |
parent | 8215de6826d126253df3b7983995262f3651e033 (diff) |
receive: pull IP header into head
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/receive.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/receive.c b/src/receive.c index 3ce472b..a6e188c 100644 --- a/src/receive.c +++ b/src/receive.c @@ -206,6 +206,9 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer, if (skb_network_header(skb) < skb->head) goto dishonest_packet_size; + if (unlikely(!(pskb_network_may_pull(skb, sizeof(struct iphdr)) && (ip_hdr(skb)->version == 4 || (ip_hdr(skb)->version == 6 && pskb_network_may_pull(skb, sizeof(struct ipv6hdr))))))) + goto dishonest_packet_type; + skb->dev = dev; skb->ip_summed = CHECKSUM_UNNECESSARY; skb->protocol = skb_examine_untrusted_ip_hdr(skb); @@ -221,6 +224,7 @@ void packet_consume_data_done(struct sk_buff *skb, struct wireguard_peer *peer, if (INET_ECN_is_ce(PACKET_CB(skb)->ds)) IP6_ECN_set_ce(skb, ipv6_hdr(skb)); } else { +dishonest_packet_type: ++dev->stats.rx_errors; ++dev->stats.rx_frame_errors; net_dbg_ratelimited("%s: Packet neither ipv4 nor ipv6 from peer %Lu (%pISpfsc)\n", netdev_pub(peer->device)->name, peer->internal_id, &peer->endpoint.addr); |