Skip to content

Fix/bind mounts type none - #1150

Merged
urunc-bot[bot] merged 3 commits into
mainfrom
fix/bind_mounts_type_none
Oct 29, 2026
Merged

urunc-bot[bot] merged 3 commits into
mainfrom
fix/bind_mounts_type_none

Conversation

@cmainas

@cmainas cmainas commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

containerd and nerdctl spell volumes as {"type": "none", "options": ["rbind", ...]}.urunc only accepted type: "bind", so such volumes never reached the guest.

  • Recognise bind mounts by their options. isBindMount now follows the OCI runtime spec and runc: a mount is a bind mount if its options include bind or rbind,regardless of its type. A mount with type: "bind" but no such option is dropped, so the e2e ctr helper now passes options=rbind.
  • Keep host kernel filesystems out of the mounted paths: Rootless runtimes replace the sysfs mount with an rbind of the host's /sys, which would otherwise end up in the virtiofs/9p share. onlyBindMounts skips, with a warning, bind mounts whose source is on sysfs, procfs, cgroupfs or another kernel filesystem, for every rootfs type.
  • Copy only regular files into a block rootfs. Sockets, FIFOs and device nodes used to break container creation and are now skipped, as directories already were.

At last, a bind mount whose source does not exist now fails container creation for every rootfs type.

Related issues

How was this tested?

With e2e tests

LLM usage

Opus 5.5

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

@netlify

netlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for urunc ready!

Name Link
🔨 Latest commit d544628
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6ae33ff4e4d820b0b34cdee0
😎 Deploy Preview https://deploy-preview-1150--urunc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cmainas
cmainas force-pushed the fix/bind_mounts_type_none branch 3 times, most recently from d139be7 to d3251f1 Compare October 26, 2026 20:55
@cmainas
cmainas marked this pull request as ready for review October 27, 2026 12:55
@cmainas
cmainas requested a review from ananos October 27, 2026 12:55
@ananos

ananos commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

thanks @cmainas! Treating bind/rbind in the options as the bind marker (like runc does) is the right fix, and nerdctl run -v host:/data (type: "none") now reaches the guest on the shared-fs, block and initrd paths. CI is green and I ran the new unit tests on a 24.04 box: they pass, and they fail when each commit's logic is reverted.

A few suggestions before I approve:

  • Silent drop for type: bind without a bind option (pkg/unikontainers/mount.go:452). For instance:

    ctr run --mount type=bind,src=/srv/data,dst=/data ...
    

    ctr leaves Options empty here. Before this PR the volume reached the guest. Now onlyBindMounts skips it and nothing is logged -- the PR had to add options=rbind to the e2e helper for this reason. runc v1.5.2 fails on this spec (mount(2) with fstype bind), so I would at least log a warning, or return an error like runc.

  • configfs is not in the host kernel FS list (mount.go:459-485). /sys/kernel/config (0x62656570) holds nvmet, LIO, USB gadget and netconsole config, and it is writable. On a 24.04 host -v /sys/kernel/config:/cfg is kept, so a virtiofs guest can write host configfs attributes through the file server. Same for fusectl, mqueue, hugetlbfs and selinuxfs. I would add unix.CONFIGFS_MAGIC at least (maybe SELINUX_MAGIC and FUSE_CTL_SUPER_MAGIC too) and extend TestOnlyBindMounts like the cgroup case.

    The check looks at the source filesystem only, not at submounts an rbind brings along (eg. -v /:/host keeps /proc and /sys under it). This matches runc, but maybe the onlyBindMounts doc comment should say "source filesystem only", so nobody reads it as a boundary.

  • No e2e case for type: "none". The nerdctl *-linux-block-mounts cases (tests/e2e/test_cases.go:375,394) use --mount type=bind, which nerdctl turns into type: "bind", so they passed before this PR too. No ctr case has volumes, so the tests/e2e/ctr.go:54 change never runs. A nerdctl -v case would cover the headline scenario.

Nits:

  • block.go:174 and :215: the filter runs twice on the block path, so the rootless /sys warning is logged twice per container.
  • block.go:255: vol%d IDs now count over the filtered list, so they shift for the same spec. Still unique, just noting.
  • The PR title is the branch name; maybe fix(mount): ... like the commits.

Rebase & merge replays cleanly on current main (only the spellcheck dict moved), so no need to rebase just for that. Happy to approve once the first two are addressed -- what do you think?

@cmainas
cmainas force-pushed the fix/bind_mounts_type_none branch from d3251f1 to f7e6e1d Compare October 29, 2026 10:58
@cmainas

cmainas commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @ananos for the review.

I have addressed the first two comments and the first nit.

For the e2e test cases, this is already handled by unit tests and adding one e2e test which is not related to e2e testing (with guest/monitor) sounds an overkill.

@ananos ananos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @cmainas! Checked f7e6e1d: type bind without a bind option now fails like runc, the kernel FS list covers configfs/fusectl/mqueue/selinuxfs/smackfs, and the filter runs once. Unit tests pass on a 24.04 box. Fair point on the e2e case. LGTM!

An OCI mount is a bind mount when its options include "bind" or
"rbind"; its Type is then a dummy that runtimes such as runc ignore.
Docker sets it to "bind", but containerd and nerdctl emit volumes
(`nerdctl run -v host:/data`) with Type "none". urunc only checked for
Type "bind", so such volumes were dropped everywhere bind mounts are
filtered: they never reached the shared rootfs of a virtiofs/9p guest,
were not copied into a block rootfs or an initrd, and were not
remounted with their VFS flags.

Add isBindMount, which follows the runtime spec and looks only at the
options, and use it in every such check (mount application, shared-fs
and block filtering). The initrd package no longer filters mounts
itself; its caller passes it only the bind mounts.

Also a mount spelled only by its Type, e.g. Type "bind" without a bind
option, is not a bind mount and is dropped like other unsupported
mounts, so make the e2e ctr helper pass the rbind option that `ctr
--mount type=bind` omits.

PR: #1150
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Reviewed-by: Anastassios Nanos <ananos@nubificus.co.uk>
Approved-by: Anastassios Nanos <ananos@nubificus.co.uk>
Rootless runtimes replace the container's sysfs mount with an rbind of
the host's /sys, e.g. with --net=host, since they cannot mount a fresh
sysfs. Now that such Type "none" binds are recognised, this mount would
end up in the rootfs shared with a virtiofs/9p guest, exposing the
host's sysfs to it and, through the file server, letting the guest
write host kernel knobs. On the block and initrd paths, single-file
binds from /proc or /sys would also copy host state into the guest.

Add onlyBindMounts as the single place that selects the spec mounts
passed to the guest: the bind mounts, minus those whose source resides
on a host kernel filesystem (sysfs, procfs, cgroupfs, securityfs,
debugfs, tracefs, bpffs, efivarfs, pstore, binfmt_misc, nsfs, configfs,
fusectl, mqueue, selinuxfs and smackfs), detected through statfs. Only
the source's own filesystem is checked, not what an rbind brings along
below it. Skipped mounts are logged. Use it for the shared-fs, initrd
and block (file copies and volumes) paths. The guest has its own kernel
and its own instances of these filesystems.

newRootfsBuilder calls it once and hands the result to the shared-fs,
initrd and block (file copies and volumes) paths, which no longer
filter on their own. filterBindMounts now only re-roots the mounts, so
rename it to rebaseBindMounts.

A bind mount whose source cannot be statfs'd, e.g. because it does not
exist, now fails container creation on every path. So does a mount with
Type "bind" or "rbind" but neither option: it is not a bind mount and
runc rejects it too, while dropping it would start the container
without the volume it asked for.

PR: #1150
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Reviewed-by: Anastassios Nanos <ananos@nubificus.co.uk>
Approved-by: Anastassios Nanos <ananos@nubificus.co.uk>
For a block rootfs, copyMountfiles copies the source of each bind mount
into the rootfs with fileFromHost, which only refused directories. Any
other special file broke container creation: opening a socket fails,
opening a FIFO blocks forever and reading a device such as /dev/urandom
never ends, filling the rootfs.

Replace ErrCopyDir with ErrNotRegularFile, which fileFromHost returns
for anything that is not a regular file, before opening it, and skip
such mounts in copyMountfiles as directories already were. This matches
the initrd path, which already copies only regular files.

PR: #1150
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Reviewed-by: Anastassios Nanos <ananos@nubificus.co.uk>
Approved-by: Anastassios Nanos <ananos@nubificus.co.uk>
@github-actions
github-actions Bot force-pushed the fix/bind_mounts_type_none branch from f7e6e1d to d544628 Compare October 29, 2026 12:45
@urunc-bot
urunc-bot Bot merged commit 54709fe into main Oct 29, 2026
4 of 7 checks passed
urunc-bot Bot pushed a commit that referenced this pull request Oct 29, 2026
An OCI mount is a bind mount when its options include "bind" or
"rbind"; its Type is then a dummy that runtimes such as runc ignore.
Docker sets it to "bind", but containerd and nerdctl emit volumes
(`nerdctl run -v host:/data`) with Type "none". urunc only checked for
Type "bind", so such volumes were dropped everywhere bind mounts are
filtered: they never reached the shared rootfs of a virtiofs/9p guest,
were not copied into a block rootfs or an initrd, and were not
remounted with their VFS flags.

Add isBindMount, which follows the runtime spec and looks only at the
options, and use it in every such check (mount application, shared-fs
and block filtering). The initrd package no longer filters mounts
itself; its caller passes it only the bind mounts.

Also a mount spelled only by its Type, e.g. Type "bind" without a bind
option, is not a bind mount and is dropped like other unsupported
mounts, so make the e2e ctr helper pass the rbind option that `ctr
--mount type=bind` omits.

PR: #1150
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Reviewed-by: Anastassios Nanos <ananos@nubificus.co.uk>
Approved-by: Anastassios Nanos <ananos@nubificus.co.uk>
urunc-bot Bot pushed a commit that referenced this pull request Oct 29, 2026
Rootless runtimes replace the container's sysfs mount with an rbind of
the host's /sys, e.g. with --net=host, since they cannot mount a fresh
sysfs. Now that such Type "none" binds are recognised, this mount would
end up in the rootfs shared with a virtiofs/9p guest, exposing the
host's sysfs to it and, through the file server, letting the guest
write host kernel knobs. On the block and initrd paths, single-file
binds from /proc or /sys would also copy host state into the guest.

Add onlyBindMounts as the single place that selects the spec mounts
passed to the guest: the bind mounts, minus those whose source resides
on a host kernel filesystem (sysfs, procfs, cgroupfs, securityfs,
debugfs, tracefs, bpffs, efivarfs, pstore, binfmt_misc, nsfs, configfs,
fusectl, mqueue, selinuxfs and smackfs), detected through statfs. Only
the source's own filesystem is checked, not what an rbind brings along
below it. Skipped mounts are logged. Use it for the shared-fs, initrd
and block (file copies and volumes) paths. The guest has its own kernel
and its own instances of these filesystems.

newRootfsBuilder calls it once and hands the result to the shared-fs,
initrd and block (file copies and volumes) paths, which no longer
filter on their own. filterBindMounts now only re-roots the mounts, so
rename it to rebaseBindMounts.

A bind mount whose source cannot be statfs'd, e.g. because it does not
exist, now fails container creation on every path. So does a mount with
Type "bind" or "rbind" but neither option: it is not a bind mount and
runc rejects it too, while dropping it would start the container
without the volume it asked for.

PR: #1150
Signed-off-by: Charalampos Mainas <charalampos.mainas@gmail.com>
Reviewed-by: Anastassios Nanos <ananos@nubificus.co.uk>
Approved-by: Anastassios Nanos <ananos@nubificus.co.uk>
@cmainas
cmainas deleted the fix/bind_mounts_type_none branch October 29, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bind mounts with type: none are ignored

2 participants