Skip to content

vfs: skip write tracking for special files on open#13149

Open
shayonj wants to merge 1 commit into
google:masterfrom
shayonj:fix-special-file-rofs
Open

vfs: skip write tracking for special files on open#13149
shayonj wants to merge 1 commit into
google:masterfrom
shayonj:fix-special-file-rofs

Conversation

@shayonj
Copy link
Copy Markdown
Contributor

@shayonj shayonj commented May 12, 2026

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

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.

Add 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.
@zkoopmans zkoopmans requested a review from nixprime May 14, 2026 22:53
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.

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

1 participant