Skip to content

Replace the manual handling of mounts with the contianerd's mount package - #840

Open
cmainas wants to merge 1 commit into
mainfrom
feat_containerd_mount_secure_join
Open

Replace the manual handling of mounts with the contianerd's mount package#840
cmainas wants to merge 1 commit into
mainfrom
feat_containerd_mount_secure_join

Conversation

@cmainas

@cmainas cmainas commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

Replace all the manual handling of mounts (option parsing, mount calls, unmounting) with containerd's mount package. Furthermore, use SecureJoin to safely resolve mount targets and copy destinations inside the monitor rootfs, so symlinks in image-controlled paths cannot redirect a mount outside of it.

Since containerd does not parse propagation flags correctly (ignores them) and because the kernel ignores per-mount VFS flags when a bind mount is created, we split the mount options in three groups: the options forwarded to containerd, the propagation flags and the per-mount VFS flags. For bind mounts we reapply the VFS flags, preserving the CL_UNPRIVILEGED locked flags of the source mount when running inside a user namespace.

Also, since we switch from moby/sys/mount to containerd's mount package we also switch from a lazy unmount to a strict one, which is necessary since we want to attach the block devices to the sandbox.

At last, fix getMonitorDevices to not append an empty device entry when /dev/net/tun does not exist on the host. Leftover from #835

Related issues

How was this tested?

with e2e tests

LLM usage

Opus 4.8 to update all calls for mounts

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.

Replace the manual handling of mount options and mount calls with
containerd's mount package, and use securejoin to resolve
mount targets and copy destinations inside the monitor rootfs, so that
symlinks in image-controlled paths cannot redirect them outside of it.

containerd's option parser cannot translate propagation flags and the
kernel ignores per-mount VFS flags when a bind mount is created.
Therefore, split the mount options into three groups: the options
forwarded to containerd, the propagation flags and the per-mount VFS
flags. For bind mounts urunc reapplies the VFS flags, preserving the
CL_UNPRIVILEGED locked flags of the source mount when running inside a
user namespace.

also, since we switch from moby/sys/mount to containerd's mount package
we also switch from a lzy unmount to a strict one, which is necessary
since we want to attach the block devices to the sandbox.

Also fix getMonitorDevices to not append an empty device entry when
/dev/net/tun does not exist on the host. Leftover from previous PR

Signed-off-by: Charalampos Mainas <cmainas@nubificus.co.uk>
@cmainas
cmainas force-pushed the feat_containerd_mount_secure_join branch from d47cd30 to 7add7b8 Compare July 20, 2026 19:46
@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit d47cd30
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a5e7b1ed3502900072330a4

@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit c218c7c
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a70457de202f0000820fe34

@cmainas
cmainas force-pushed the feat_containerd_mount_secure_join branch from 7add7b8 to ec2cdb8 Compare July 29, 2026 16:59
@cmainas
cmainas force-pushed the feat_containerd_mount_secure_join branch 5 times, most recently from 1a5b996 to c218c7c Compare August 3, 2026 07:38
@cmainas
cmainas marked this pull request as ready for review August 3, 2026 07:38
@cmainas
cmainas requested a review from ananos August 3, 2026 07:38
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.

Replace all manually handled mounts with containerd's mount helper

1 participant