From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>,
Chris Wright <chrisw@redhat.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] vxlan: virtual extensible lan
Date: Mon, 24 Sep 2012 21:39:07 +0200 [thread overview]
Message-ID: <1348515547.26828.1538.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120924185050.162920909@vyatta.com>
On Mon, 2012-09-24 at 11:43 -0700, Stephen Hemminger wrote:
> +/* Callback from net/ipv4/udp.c to receive packets */
> +static int vxlan_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
> +{
> + struct iphdr *oip = ip_hdr(skb);
oip is set to ip_hdr(skb)
> + struct vxlanhdr *vxh;
> + struct vxlan_dev *vxlan;
> + struct vxlan_stats *stats;
> + __u32 vni;
> + __be32 saddr = oip->saddr; /* source address for learning */
> + __be32 daddr = oip->daddr; /* destination for checking */
> +
> + /* pop off outer UDP header */
> + __skb_pull(skb, sizeof(struct udphdr));
> +
> + /* Need Vxlan and inner Ethernet header to be present */
> + if (!pskb_may_pull(skb,
> + sizeof(struct vxlanhdr) + sizeof(struct ethhdr)))
> + goto error;
> +
here oip may points to a freed memory, if pskb_may_pull) has to
reallocate skb->head
> + /* Drop packets with reserved bits set */
> + vxh = (struct vxlanhdr *) skb->data;
> + if (vxh->vx_flags != htonl(VXLAN_FLAGS) ||
> + (vxh->vx_vni & htonl(0xff)))
> + goto error;
> +
> + __skb_pull(skb, sizeof(struct vxlanhdr));
> +
> + /* Is this VNI defined? */
> + vni = ntohl(vxh->vx_vni) >> 8;
> + vxlan = vxlan_find_vni(sock_net(sk), vni);
> + if (!vxlan)
> + goto drop;
> +
> + /* Ignore packets if device is not up */
> + if (!netif_running(vxlan->dev))
> + goto drop;
> +
> + /* Re-examine inner Ethernet packet */
> + skb->protocol = eth_type_trans(skb, vxlan->dev);
> + skb->ip_summed = CHECKSUM_NONE;
> +
> + /* Ignore packet loops (and multicast echo) */
> + if (compare_ether_addr(eth_hdr(skb)->h_source,
> + vxlan->dev->dev_addr) == 0)
> + goto drop;
> +
> + /* Check for multicast group configuration errors */
> + if (IN_MULTICAST(ntohl(daddr)) &&
> + daddr != vxlan->gaddr) {
> + if (net_ratelimit())
> + netdev_notice(vxlan->dev,
> + "group address %pI4 does not match\n",
> + &daddr);
> + goto drop;
> + }
> +
> + if (vxlan->learn)
> + vxlan_snoop(skb->dev, saddr, eth_hdr(skb)->h_source);
> +
> + stats = this_cpu_ptr(vxlan->stats);
> + u64_stats_update_begin(&stats->syncp);
> + stats->rx_packets++;
> + stats->rx_bytes += skb->len;
> + u64_stats_update_end(&stats->syncp);
> +
> + __skb_tunnel_rx(skb, vxlan->dev);
> + skb_reset_network_header(skb);
> + vxlan_ecn_decap(oip, skb);
potential crash
next prev parent reply other threads:[~2012-09-24 19:39 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-24 18:43 [PATCH net-next 0/3] VXLAN driver Stephen Hemminger
2012-09-24 18:43 ` [PATCH net-next 1/3] netlink: add attributes to fdb interface Stephen Hemminger
2012-09-24 18:43 ` [PATCH net-next 2/3] igmp: export symbol ip_mc_leave_group Stephen Hemminger
2012-09-24 18:43 ` [PATCH net-next 3/3] vxlan: virtual extensible lan Stephen Hemminger
2012-09-24 19:33 ` Eric Dumazet
2012-09-24 19:39 ` Eric Dumazet [this message]
2012-09-24 19:46 ` [PATCHv2 " Stephen Hemminger
2012-09-24 19:55 ` Eric Dumazet
2012-09-24 20:02 ` [PATCHv3 " Stephen Hemminger
2012-09-24 20:24 ` John Fastabend
2012-09-24 20:27 ` Stephen Hemminger
2012-09-24 23:17 ` John Fastabend
2012-09-24 20:09 ` [PATCHv2 " Eric Dumazet
2012-09-24 20:26 ` Stephen Hemminger
2012-09-24 20:41 ` Eric Dumazet
2012-09-24 20:58 ` [PATCH " Chris Wright
2012-09-24 21:11 ` Stephen Hemminger
2012-09-24 21:22 ` Chris Wright
2012-09-24 21:44 ` [RFC] gre: conform to RFC6040 ECN progogation Stephen Hemminger
2012-09-24 22:25 ` Eric Dumazet
2012-09-24 22:30 ` Stephen Hemminger
2012-09-25 5:17 ` Eric Dumazet
2012-10-01 15:55 ` Ben Hutchings
2012-10-01 15:56 ` Stephen Hemminger
2012-10-01 16:49 ` Ben Hutchings
2012-10-01 17:13 ` Eric Dumazet
2012-10-01 21:21 ` Stephen Hemminger
2012-09-24 21:50 ` [PATCHv4 net-next] vxlan: virtual extensible lan Stephen Hemminger
2012-09-25 21:55 ` Jesse Gross
2012-09-25 22:03 ` Stephen Hemminger
2012-09-25 22:09 ` [PATCHv5 " Stephen Hemminger
2012-09-27 22:47 ` David Miller
2012-09-27 23:00 ` Stephen Hemminger
2012-09-27 23:12 ` David Miller
2012-10-01 20:57 ` [PATCHv6 " Stephen Hemminger
2012-10-01 22:07 ` David Miller
2012-10-01 22:23 ` Stephen Hemminger
2012-10-01 22:30 ` Stephen Hemminger
2012-10-01 22:34 ` David Miller
[not found] ` <20121001140206.2bbf9c41@nehalam.linuxnetplumber.net>
2012-10-01 21:02 ` [PATCH 2/2] iproute2: manage VXLAN forwarding entries Stephen Hemminger
2012-10-01 21:02 ` [PATCH 1/2] iproute2: vxlan support Stephen Hemminger
2012-09-26 4:36 ` [PATCHv4 net-next] vxlan: virtual extensible lan Stephen Hemminger
2012-09-27 17:20 ` Jesse Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1348515547.26828.1538.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=chrisw@redhat.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox