netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: fix sysfs symlinks of adjacent devices
@ 2014-09-12 10:13 Alexander Fomichev
  2014-09-12 13:33 ` Vlad Yasevich
  2014-09-19  8:59 ` [PATCH net] net: fix sysfs symlinks of adjacent devices Andres Freund
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Fomichev @ 2014-09-12 10:13 UTC (permalink / raw)
  To: netdev
  Cc: David Miller, Cong Wang, Vlad Yasevich, Andres Freund,
	Alexander Y. Fomichev

From: "Alexander Y. Fomichev" <git.user@gmail.com>

__netdev_adjacent_dev_insert may add adjacent device from another
namespace. Without proper check it leads to emergence of broken
symlink from/to device not existing in current namespace.
Fix: check net_ns is the same before netdev_adjacent_sysfs_add/del
related to: 4c75431ac3520631f1d9e74aa88407e6374dbbc4

Signed-off-by: Alexander Y. Fomichev <git.user@gmail.com>
---
 net/core/dev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index ab9a16530c36..887784b2dcde 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4841,7 +4841,8 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
 	pr_debug("dev_hold for %s, because of link added from %s to %s\n",
 		 adj_dev->name, dev->name, adj_dev->name);
 
-	if (netdev_adjacent_is_neigh_list(dev, dev_list)) {
+	if (netdev_adjacent_is_neigh_list(dev, dev_list) &&
+	    net_eq(dev_net(dev), dev_net(adj_dev))) {
 		ret = netdev_adjacent_sysfs_add(dev, adj_dev, dev_list);
 		if (ret)
 			goto free_adj;
@@ -4862,7 +4863,8 @@ static int __netdev_adjacent_dev_insert(struct net_device *dev,
 	return 0;
 
 remove_symlinks:
-	if (netdev_adjacent_is_neigh_list(dev, dev_list))
+	if (netdev_adjacent_is_neigh_list(dev, dev_list) &&
+	    net_eq(dev_net(dev), dev_net(adj_dev)))
 		netdev_adjacent_sysfs_del(dev, adj_dev->name, dev_list);
 free_adj:
 	kfree(adj);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-09-19  8:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-12 10:13 [PATCH net] net: fix sysfs symlinks of adjacent devices Alexander Fomichev
2014-09-12 13:33 ` Vlad Yasevich
2014-09-14 21:45   ` David Miller
2014-09-15 10:18     ` Alexander Y. Fomichev
2014-09-15 10:22     ` [PATCH net] net: fix creation adjacent device symlinks Alexander Fomichev
2014-09-15 18:25       ` David Miller
2014-09-19  8:59 ` [PATCH net] net: fix sysfs symlinks of adjacent devices Andres Freund

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).