Skip to content

[bug] Can't mount /proc/net/dev #4771

Closed

Description

@lifubang

Though the mount destination path /proc/net/dev is in the mount whitelist, but we still can't mount it in the container.

root@acmcoder:/opt/ubuntu# docker run --rm -v /mynetdev:/proc/net/dev busybox cat /proc/net/dev
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/mynetdev" to rootfs at "/proc/net/dev": create mountpoint for /proc/net/dev mount: check proc-safety of /proc/net/dev mount: "/var/lib/docker/overlay2/4003a74c35de34187abfc1fdcb8509d321d8f9319cce28957a5ee5569e40ad8d/merged/proc/1/net/dev" cannot be mounted because it is inside /proc: unknown.

Activity

  1. added theissue type on May 27, 2025
  2. rata commented on Jul 14, 2025

    @rata
    Member

    @lifubang why do you want to mount on top of that? Do you want to hide some stats? Or fake them? Is namespaces what is exposed there or the whole host?

  3. cyphar commented on Jul 20, 2025

    @cyphar
    Member

    I think /proc/net/dev being added to the allow-list is a mistake and we should just remove it:

    1. It is not a global property, /proc/net is a symlink to /proc/self/net (which means /proc/1/net when runc is setting up mounts). Mounting over non-global properties like this makes very little sense in general -- most programs will look at their own configurations (which is also at /proc/net/... for them) which will not contain the overmounts and thus the mount will be useless, and non-privileged programs will probably not even have access to /proc/1/... information.
    2. The justification that this is "for lxcfs" is wrong, because lxcfs has never mounted such files (mounting over per-process files does not scale well and requires a lot of extra management infrastructure that lxc does not use, nor want). lxcfs only has overmounts for /proc/cpuinfo, /proc/meminfo and a few other global /proc files.
    3. The kernel is slowly moving towards denying these kinds of mounts entirely -- upon my insistence, Linux 6.12 blocked mounts on top of /proc/self/fd, /proc/self/fdinfo, and /proc/self/map_files and future versions of Linux will probably end up blocking everything in /proc/$pid/*.
    4. I don't see why you would even want to mount on top of /proc/net/dev -- /proc/self/net is already namespaced with network namespaces, and the contents of /proc/self/net are already correct for the container! Why would you ever need to fake the contents of that file?!

    EDIT: The error is coming from the fact that /proc/net is a symlink to self/net, which gets expanded before we check in checkProcMount. I suspect this overmount has never worked, and should never have been added. I'll send a patch to remove it.

  4. cyphar commented on Jul 20, 2025

    @cyphar
    Member

    FWIW, this was added in 2ee9cbb (#560) and there is no explanation for why /proc/net/dev is special.

  5. lifubang commented on Jul 21, 2025

    @lifubang
    MemberAuthor

    @lifubang why do you want to mount on top of that? Do you want to hide some stats? Or fake them? Is namespaces what is exposed there or the whole host?

    I’ve never used this feature myself — I only came across it during a code review.

    Looking at the commit provided by @cyphar, I found the original comment:

    // These entries can be bind mounted by files emulated by fuse,
    // so commands like top, free displays stats in container.
    

    However, I believe this mount point has likely been unusable for years, and there may not be any real-world usage of it anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions