lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1372277614-17506-1-git-send-email-pshelar@nicira.com>
Date:	Wed, 26 Jun 2013 13:13:34 -0700
From:	Pravin B Shelar <pshelar@...ira.com>
To:	netdev@...r.kernel.org, dev@...nvswitch.org,
	stephen@...workplumber.org
Cc:	Pravin B Shelar <pshelar@...ira.com>
Subject: [PATCH vxlan v2 2/8] vxlan: Fix vs->vni_list locking.

Use rtnl lock to protect vs->vni_list updates.

Signed-off-by: Pravin B Shelar <pshelar@...ira.com>
---
 drivers/net/vxlan.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 0ba1e7e..f658d39 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1321,13 +1321,16 @@ static int vxlan_init(struct net_device *dev)
 		/* If we have a socket with same port already, reuse it */
 		atomic_inc(&vs->refcnt);
 		vxlan->vn_sock = vs;
+		spin_unlock(&vn->sock_lock);
+		rtnl_lock();
 		hlist_add_head_rcu(&vxlan->hlist, vni_head(vs, vni));
+		rtnl_unlock();
 	} else {
+		spin_unlock(&vn->sock_lock);
 		/* otherwise make new socket outside of RTNL */
 		dev_hold(dev);
 		queue_work(vxlan_wq, &vxlan->sock_work);
 	}
-	spin_unlock(&vn->sock_lock);
 
 	return 0;
 }
@@ -1644,16 +1647,21 @@ static void vxlan_sock_work(struct work_struct *work)
 	if (ovs) {
 		atomic_inc(&ovs->refcnt);
 		vxlan->vn_sock = ovs;
-		hlist_add_head_rcu(&vxlan->hlist, vni_head(ovs, vni));
 		spin_unlock(&vn->sock_lock);
 
+		rtnl_lock();
+		hlist_add_head_rcu(&vxlan->hlist, vni_head(ovs, vni));
+		rtnl_unlock();
+
 		sk_release_kernel(nvs->sock->sk);
 		kfree(nvs);
 	} else {
 		vxlan->vn_sock = nvs;
 		hlist_add_head_rcu(&nvs->hlist, vs_head(net, port));
-		hlist_add_head_rcu(&vxlan->hlist, vni_head(nvs, vni));
 		spin_unlock(&vn->sock_lock);
+		rtnl_lock();
+		hlist_add_head_rcu(&vxlan->hlist, vni_head(nvs, vni));
+		rtnl_unlock();
 	}
 out:
 	dev_put(dev);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ