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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 4 Jul 2013 14:20:55 +0800
From:	Fan Du <fan.du@...driver.com>
To:	<ebiederm@...ssion.com>
CC:	<serge.hallyn@...onical.com>, <davem@...emloft.net>,
	<netdev@...r.kernel.org>
Subject: [PATCH] net namespace: wrap for_each_net with rtnl_lock

The read access to net_namespace_list with for_each_net should always
be protected with rtnl_lock agiast any adding/removing operation from
the list.

Signed-off-by: Fan Du <fan.du@...driver.com>
---
 net/core/net_namespace.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index f976520..f3808ff 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -445,12 +445,14 @@ static int __register_pernet_operations(struct list_head *list,
 
 	list_add_tail(&ops->list, list);
 	if (ops->init || (ops->id && ops->size)) {
+		rtnl_lock();
 		for_each_net(net) {
 			error = ops_init(ops, net);
 			if (error)
 				goto out_undo;
 			list_add_tail(&net->exit_list, &net_exit_list);
 		}
+		rtnl_unlock();
 	}
 	return 0;
 
@@ -468,8 +470,10 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
 	LIST_HEAD(net_exit_list);
 
 	list_del(&ops->list);
+	rtnl_lock();
 	for_each_net(net)
 		list_add_tail(&net->exit_list, &net_exit_list);
+	rtnl_unlock();
 	ops_exit_list(ops, &net_exit_list);
 	ops_free_list(ops, &net_exit_list);
 }
-- 
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