Skip to content

mnt: apply readonly recursively to bind submounts - #370

Closed
mcc0nnell wants to merge 1 commit into
google:masterfrom
mcc0nnell:fix/mnt-newapi-recursive-readonly
Closed

mcc0nnell wants to merge 1 commit into
google:masterfrom
mcc0nnell:fix/mnt-newapi-recursive-readonly

Conversation

@mcc0nnell

Copy link
Copy Markdown
Contributor

Summary

Apply MS_RDONLY together with the other per-mount restrictions when the new mount API clones a recursive bind subtree.

open_tree(..., AT_RECURSIVE) clones nested submounts, but doBindMountAt() previously stripped MS_RDONLY before the recursive mount_setattr() call. The later bind remount only affects the top mount. With a writable jail root, nested submounts could therefore remain writable.

This passes the full requested flag set to applyMountFlags(), so MOUNT_ATTR_RDONLY is applied recursively before move_mount().

Fixes #369.

Validation

  • Project Dockerfile builds successfully with the patch.
  • New mount API smoke test exits successfully on Linux 6.8.
  • Focused kernel-level reproduction using a recursive open_tree() clone with a nested tmpfs:
    • before: top bind read-only, nested tmpfs writable
    • after recursive MOUNT_ATTR_RDONLY: top bind read-only, nested tmpfs read-only
  • git diff --check passes.

This intentionally does not change the separate mount-attribute failure handling tracked in #312.

@mcc0nnell

Copy link
Copy Markdown
Contributor Author

Superseded by #371, which includes the same recursive-readonly correction plus fail-closed handling and a privilege-gated regression for nested tmpfs, writable recursive binds, and read-only file binds. Consolidating review on #371 to avoid duplicate PRs. Thanks!

@mcc0nnell mcc0nnell closed this Oct 23, 2026
@mcc0nnell
mcc0nnell deleted the fix/mnt-newapi-recursive-readonly branch October 23, 2026 14:07
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.

mnt_newapi: MS_RDONLY not applied recursively to nested submounts of bind mounts when root is rw

1 participant