Skip to content

vfs: skip write tracking for special files on open - #13996

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl959292441
Open

vfs: skip write tracking for special files on open#13996
copybara-service[bot] wants to merge 1 commit into
masterfrom
test/cl959292441

Conversation

@copybara-service

Copy link
Copy Markdown

vfs: skip write tracking for special files on open

Linux skips the mount-level write check when opening a character device, block device, FIFO, or socket, so write-opening /dev/null on a read-only bind mount succeeds. gVisor was running that check unconditionally and returning EROFS, which breaks buildah's mount-bind-then-RO-remount hardening pattern when used under runsc.

This adds an IsSpecialFile option on FileDescription, paired across the open and close paths so the writer counter stays balanced, and set it on every open path that backs a special-file inode. The socket and host-imported FDs live on internal disconnected mounts that are never remounted RO, so flagging them is a no-op today and exists for parity with the kernel's predicate.

Fixes: #13148
FUTURE_COPYBARA_INTEGRATE_REVIEW=#13149 from shayonj:fix-special-file-rofs 87673b0

Linux skips the mount-level write check when opening a character device, block device, FIFO, or socket, so write-opening /dev/null on a read-only bind mount succeeds. gVisor was running that check unconditionally and returning EROFS, which breaks buildah's mount-bind-then-RO-remount hardening pattern when used under runsc.

This adds an `IsSpecialFile` option on `FileDescription`, paired across the open and close paths so the writer counter stays balanced, and set it on every open path that backs a special-file inode. The socket and host-imported FDs live on internal disconnected mounts that are never remounted RO, so flagging them is a no-op today and exists for parity with the kernel's predicate.

Fixes: #13148
FUTURE_COPYBARA_INTEGRATE_REVIEW=#13149 from shayonj:fix-special-file-rofs 87673b0
PiperOrigin-RevId: 959292441
@copybara-service copybara-service Bot added the exported Issue was exported automatically label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exported Issue was exported automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Writing to /dev/null fails with EROFS on a read-only bind mount

1 participant