All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: mike.rapoport@ravellosystems.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] net: vxlan: fix crash when interface is created with no group
Date: Thu, 20 Mar 2014 16:02:29 -0400 (EDT)	[thread overview]
Message-ID: <20140320.160229.857536522237793124.davem@davemloft.net> (raw)
In-Reply-To: <1395055050-20874-1-git-send-email-mike.rapoport@ravellosystems.com>

From: Mike Rapoport <mike.rapoport@ravellosystems.com>
Date: Mon, 17 Mar 2014 13:17:30 +0200

> If the vxlan interface is created without group definition, there is a
> panic on the first packet reception:
 ...
> The crash occurs because vxlan_rcv decides on protocol version of outer
> packed using vxlan->default_dst.remote_ip.sa.sa_family field which is
> not initialized if no multicast group was specified at interface
> creation time. This causes vxlan driver to always assume that outer
> packet is IPv6.
> 
> Using IP protocol version from skb instead of default destination
> address family fixes the problem.
> 
> Signed-off-by: Mike Rapoport <mike.rapoport@ravellosystems.com>

Thinking some more, I'd like to propose an alternate version of this fix.

Any objections to this?  I think it maintains the pre-ipv6-support
behavior.  I know there may be some concerns about supporting multiple
families on the same socket, but I'm not so sure the code is able to
support that right now anyways.

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index a7eb3f2..3a23623 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1206,7 +1206,7 @@ static void vxlan_rcv(struct vxlan_sock *vs,
 		goto drop;
 
 	/* Re-examine inner Ethernet packet */
-	if (remote_ip->sa.sa_family == AF_INET) {
+	if (vs->family == AF_INET) {
 		oip = ip_hdr(skb);
 		saddr.sin.sin_addr.s_addr = oip->saddr;
 		saddr.sa.sa_family = AF_INET;
@@ -2409,10 +2409,13 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
 
 	INIT_WORK(&vs->del_work, vxlan_del_work);
 
-	if (ipv6)
+	if (ipv6) {
+		vs->family = AF_INET6;
 		sock = create_v6_sock(net, port);
-	else
+	} else {
+		vs->family = AF_INET;
 		sock = create_v4_sock(net, port);
+	}
 	if (IS_ERR(sock)) {
 		kfree(vs);
 		return ERR_CAST(sock);
diff --git a/include/net/vxlan.h b/include/net/vxlan.h
index 5deef1a..6f00731 100644
--- a/include/net/vxlan.h
+++ b/include/net/vxlan.h
@@ -16,6 +16,7 @@ struct vxlan_sock {
 	struct hlist_node hlist;
 	vxlan_rcv_t	 *rcv;
 	void		 *data;
+	__u16		  family;
 	struct work_struct del_work;
 	struct socket	 *sock;
 	struct rcu_head	  rcu;

  parent reply	other threads:[~2014-03-20 20:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17 11:17 [PATCH net] net: vxlan: fix crash when interface is created with no group Mike Rapoport
2014-03-17 16:34 ` Stephen Hemminger
2014-03-18 15:10 ` Or Gerlitz
2014-03-18 15:51   ` Mike Rapoport
2014-03-19  3:20     ` David Miller
2014-03-19  6:56       ` Mike Rapoport
2014-03-18 16:41 ` Cong Wang
2014-03-18 16:55 ` David Stevens
2014-03-18 18:07   ` Cong Wang
2014-03-19  7:14   ` Mike Rapoport
2014-03-19 19:46     ` David Miller
2014-03-19 19:52       ` Mike Rapoport
2014-03-19 22:29         ` David Miller
2014-03-19 20:28     ` David Stevens
2014-03-20  3:40       ` David Miller
2014-03-19 14:08   ` David Stevens
2014-03-19 14:32     ` Mike Rapoport
2014-03-19 14:40     ` David Stevens
2014-03-20 20:02 ` David Miller [this message]
2014-03-21  5:06   ` Mike Rapoport
2014-03-20 20:47 ` David Stevens
2014-03-21 10:22   ` Mike Rapoport
2014-03-21 11:22   ` David Stevens
2014-03-21 15:31     ` Mike Rapoport
2014-03-23  9:27     ` Mike Rapoport
2014-03-23 14:43       ` Or Gerlitz
2014-03-26  0:53         ` David Miller
2014-03-26  9:47           ` Mike Rapoport
2014-03-26 14:47           ` David Stevens
2014-03-26 17:50             ` Mike Rapoport
2014-03-27 20:20               ` Cong Wang
2014-03-28  9:05                 ` Mike Rapoport
2014-03-29  8:29           ` Mike Rapoport
2014-03-31 20:18             ` David Miller
2014-03-24  5:09       ` Pravin Shelar
2014-04-01  6:23 Mike Rapoport
2014-04-01 19:22 ` Cong Wang
2014-04-02  5:51   ` Mike Rapoport
2014-04-03 15:19 ` David Miller

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=20140320.160229.857536522237793124.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=mike.rapoport@ravellosystems.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.