Skip to content

Fix /proc/net in presence of net namespaces

Pavel Emelyanov containers lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2Add an id to struct netinclude/net/net_namespace.h net/core/net_namespace.c+19 -10 replies
2/2Make /proc/net a symlink and drop proc shadowsfs/proc/generic.c fs/proc/proc_net.c include/linux/proc_fs.h +1 more+69 -380 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] Fix /proc/net in presence of net namespaces

Current /proc/net is done with so called "shadows", but current implementation is broken and has little chances to get fixed.

The problem is that dentries subtree of /proc/net directory has fancy revalidation rules to make processes living in different net namespaces see different entries in /proc/net subtree, but currently, tasks see in the /proc/net subdir the contents of any other namespace, depending on who opened the file first.

The proposed fix is to turn /proc/net into a symlink, which behaves similar to /proc/self link - it points to .netns/<id> directory where the <id> is the id of net namespace, current task lives in.

# ls -l /proc/net
lrwxrwxrwx  1 root root 8 Feb 28 18:38 /proc/net -> .netns/0

The /proc/.netns dir contains subtrees for all the namespaces in the system:

# ls -l /proc/.netns/
total 0
dr-xr-xr-x  5 root root 0 Feb 28 18:39 0
dr-xr-xr-x  3 root root 0 Feb 28 18:39 1

To provide some security each /proc/.netns/<id> directory allows access to tasks that live in the owning namespace only (with the exception, that init_net tasks can see everything).