net: prevent of emerging cross-namespace symlinks
authorAlexander Y. Fomichev <git.user@gmail.com>
Mon, 25 Aug 2014 12:26:45 +0000 (16:26 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Jan 2015 16:18:59 +0000 (08:18 -0800)
commit565318483e521ee292e9e1c74dba169481b631bf
treee4d715faa6be51aea13be61751c31b955868884e
parente8480fd4697b9ac7f0fe96cde4c123f1d6e2892d
net: prevent of emerging cross-namespace symlinks

commit 4c75431ac3520631f1d9e74aa88407e6374dbbc4 upstream.

Code manipulating sysfs symlinks on adjacent net_devices(s)
currently doesn't take into account that devices potentially
belong to different namespaces.

This patch trying to fix an issue as follows:
- check for net_ns before creating / deleting symlink.
  for now only netdev_adjacent_rename_links and
  __netdev_adjacent_dev_remove are affected, afaics
  __netdev_adjacent_dev_insert implies both net_devs
  belong to the same namespace.
- Drop all existing symlinks to / from all adj_devs before
  switching namespace and recreate them just after.

Signed-off-by: Alexander Y. Fomichev <git.user@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Miquel van Smoorenburg <mikevs@xs4all.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/dev.c