Skip to content

fix(virtiofs): scope host-edge read-only to directory bind mounts#233

Closed
ndeloof wants to merge 1 commit into
containerd:mainfrom
ndeloof:host-edge-ro-directory-only
Closed

fix(virtiofs): scope host-edge read-only to directory bind mounts#233
ndeloof wants to merge 1 commit into
containerd:mainfrom
ndeloof:host-edge-ro-directory-only

Conversation

@ndeloof

@ndeloof ndeloof commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

bindMounter marks a virtio-fs share read-only at the host edge whenever the OCI bind mount carries the ro option. For a file bind mount this is incorrect: virtio-fs operates on directories, so a file mount is backed by sharing its parent directory. That parent typically contains unrelated writable files — the container's own runtime state and stdio fifos — so flagging the whole share read-only at the host edge denies writes to those siblings and stalls container start.

Fix

Only directory bind mounts get host-edge read-only, where the shared device maps exactly to the read-only mount. A read-only file bind mount keeps its read-only guarantee through the guest ro mount option that is still preserved in the OCI spec (defense in depth — unchanged behavior for files).

Test plan

  • go build ./...
  • Directory ro bind mount: writes are rejected at the host edge and cannot be re-enabled from inside the guest.
  • File ro bind mount: container starts normally; sibling runtime files in the shared parent stay writable; the mounted file itself stays read-only via the guest mount.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings June 22, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

A read-only file bind mount shares its *parent* directory via virtio-fs
(virtio-fs operates on directories), and that parent typically holds
unrelated writable files — the container's own runtime state and stdio
fifos. Marking the whole share read-only at the host edge therefore
denies writes to those siblings and stalls container start.

Restrict host-edge read-only to directory bind mounts, where the share
maps exactly to the read-only mount. A read-only file bind mount keeps
its read-only guarantee through the guest `ro` mount option preserved in
the OCI spec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof force-pushed the host-edge-ro-directory-only branch from 883e79c to 501f26a Compare June 22, 2026 15:53
@ndeloof

ndeloof commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Superseding this with a downstream fix: downstram stops marking its own generated /etc files (resolv.conf, trust-store bundle) read-only, so a read-only file mount no longer makes its shared parent directory read-only at the host edge. That removes the need for this directory-only refinement on the nerdbox side for the immediate use case. Closing for now; can revisit if a general nerdbox-side guard is wanted later.

@ndeloof ndeloof closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants