#5474·runc

`--preserve-fds` leaks runc's own file descriptors when fewer FDs are actually passed

Author: maluffCreated Sep 15, 2026Updated Sep 15, 2026

Description

runc run --preserve-fds=N does not verify that the caller actually passed N file descriptors. If fewer (or none) are passed, runc passes whatever happens to occupy those descriptor numbers at that point in its own execution. Those are runc's own internal file descriptors, and they end up in the container's init process.

Steps to reproduce the issue

  1. Start a container with --preserve-fds without passing any file descriptors:
bash
sudo runc run --preserve-fds=3 test_container
  1. Inspect the descriptors of the container's init process from the host:
bash
sudo ls -l /proc/$(sudo runc state test_container | grep -o '"pid": [0-9]*' | grep -o '[0-9]*')/fd/

Describe the results you received and expected

Received: The container process inherits file descriptors belonging to runc. With our setup on a default rootful configuration, these resolved to /sys/fs/cgroup and to /sys/fs/cgroup/user.slice/user-<uid>.slice/session-<id>.scope/cpu.max. No warning or error is emitted. Expected: runc should detect and report when fewer file descriptors are given than stated in --preserve-fds. E.g.:

file descriptor 3 is not available - the preserve-fds option requires that file descriptors must be passed

What version of runc are you using?

runc version 1.5.1 spec: 1.3.0 go: go1.26.5-X:nodwarf5 libseccomp: 2.6.0 libpathrs: 0.2.6

Host OS information

NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo

Host kernel information

Linux 6.18.50-2-lts