Repository navigation
feat(mount): a read-only mount that can actually be turned on (#532) - #536
Merged
Merged
Conversation
The enforcement has been complete since v0.11.0 and unreachable the whole time. internal/fuse returned EROFS from thirteen entry points, mount.go appended the kernel's own `ro`, platform.go copied MountOptions.ReadOnly into the go-fuse config — and nothing in the tree ever set MountOptions.ReadOnly. internal/config had no read_only key, so a config file asking for one was rejected as unknown, and internal/fuse's own yaml:"read_only" tag has never decoded a byte because nothing unmarshals into that package. A tested implementation with no way to reach it, which is the defect platform.go already records in the past tense about its predecessor. Adds `mount.read_only` to internal/config, one line each in buildMountOptions and buildWriterOptions, `--read-only` on the mount subcommand, and a backstop in internal/vfs. The mount helper's `ro` is a translation now instead of a refusal. The vfs backstop goes through a new mutatingNode rather than node itself: node is not a write chokepoint — ReadAt and FileSize call it to overlay pending writes and to report sizes that include them — so gating it would EROFS every read, which is the opposite of the feature. --read-only is one-way. A bool flag cannot tell "absent" from "given as false", so an unconditional assignment would make every plain `objectfs mount` override a config file that said read_only: true. For the same reason mount.objectfs lets `ro` beat `rw` in either order, where mount(8) would let the last win. Proven at the endpoint. The new internal/fuse tests run against a real in-process S3 endpoint over real HTTP and assert its request log holds no PUT, POST or DELETE across any key, because an errno is a claim ObjectFS makes about itself and all thirteen of those errno gates were already correct on a mount that accepted writes. A companion test asserts no operation returns EROFS on a writable mount — several fail for other reasons, and a refusal for the wrong reason is still a refusal. A third builds the configuration the program cannot produce, write path read-only with the FUSE gate off, to show the backstop holds when an entry point forgets.
…532) Two layers that each cover the other's absence is what was wanted at runtime and what makes a mutation undetectable: delete the gate at filesystem.go:1330 and the refusal test stays green, because the vfs backstop answers with the same errno. So this runs the same thirteen entry points with the FUSE gate armed and the write path writable — a configuration internal/adapter cannot produce — so any EROFS came from the gate itself. With TestTheWriterBackstopHoldsWithoutTheFUSEGate covering the other direction, neither layer can stand in for the other in a test.
…532) The flag was parsed and connected to nothing that any test could see: deleting the override arm from applyCommandLineOverrides left every package green, which is #532's own defect one layer up. Two subtests now cover it — the flag reaching Mount.ReadOnly, and an invocation without it leaving a config file's read_only: true alone, which is the failure an unconditional assignment would cause and which nobody notices until something has been overwritten. Also corrects a gate count that was written from the plan rather than the source: thirteen ReadOnly gates in internal/fuse, not ten. Mkdir, Create, Unlink, Rmdir, Rename, Open, Write, Setattr on a file and on a directory, and Setxattr and Removexattr on each.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #532.
What was actually missing
The read-only enforcement has been complete since v0.11.0 and unreachable the whole time:
internal/fuseEROFS gatesfilesystem.go,rename.go,attributes.go,xattr.gorooptionmount.go:523appends it whenOptions.ReadOnlyMountOptions.ReadOnly→ go-fuseplatform.go:93MountOptions.ReadOnlybuildMountOptionsset six fields and not that oneinternal/configread_onlykey at all, so a config file asking for one was rejected as unknownvfs.ErrReadOnlyerrno.go:58, never returnedinternal/fuse/mount.go's ownyaml:"read_only"tag is a red herring — nothing in the treeunmarshals YAML into that package, so it has never decoded a byte. This is the same defect
internal/fuse/platform.go:43records in the past tense about its own predecessor, and the same classas #180's nine
MountOptionsfields that named real capabilities and reached nothing. A testedimplementation with no way to turn it on.
What this adds
mount.read_onlyininternal/config,--read-onlyonobjectfs mount, and-o roin an/etc/fstabentry, which/sbin/mount.objectfsnow translates instead of refusing.buildMountOptionsandbuildWriterOptions— the two mappings whose absence wasthe whole bug.
internal/vfs, through a newmutatingNoderather than throughnodeitself.nodeis not a write chokepoint:ReadAtandFileSizecall it to overlay pending writes andto report sizes that include them, so gating it — the obvious implementation — returns EROFS for
every read, which is the opposite of the feature.
Three enforcing layers, and the redundancy is the design:
internal/vfsso that "nothing is dirty" isa property of the layer that owns dirty state rather than a convention every caller observes;
internal/fuseso the errno is EROFS at the syscall the application made, which is what tellscpand
tarto stop where EACCES sends an operator digging through bucket policies; and the kernel's ownroso the mount reports itself correctly tomount(8)andstatfs.Two decisions worth reviewing
mount.read_only, notfuse.read_only— a deviation from the approved plan. Thefuseblock isscoped to how the kernel is asked to cache and dispatch, settings whose whole effect is the kernel's
behavior. This one's effect is mostly ObjectFS's own and holds whether or not the kernel was told
anything, so filing it under
fusewould describe a guarantee as a dispatch flag. Reasoned out at thefield, in
buildMountOptionsand inbuildWriterOptions.--read-onlyis one-way, androbeatsrwin either order. A bool flag cannot distinguish"absent" from "given as false", so an unconditional assignment would make every plain
objectfs mountsilently override a config file that said
read_only: true. For the same reason the mount helper letsrowin whichever order-o ro,rwputs them in, wheremount(8)would let the last one win: the twooutcomes are not equally bad. Read-only where they meant read-write is a write that gets refused and
noticed; the other direction is bytes overwritten in a bucket they asked to protect. Both pinned by
tests rather than left to fall out of a table.
Proven at the endpoint, and each layer proven without the other
The
internal/fusetests run against a real in-process S3 endpoint over real HTTP and assert itsrequest log holds no PUT, POST or DELETE across any key — not just the key the test named, because
the failure includes a directory marker for the refused Mkdir or the copy half of a refused Rename. An
errno is a claim ObjectFS makes about itself; the request log is not, and all thirteen errno gates were
already correct on a build whose mounts accepted writes.
Three tests that exist because of what the others cannot see:
TestWritableMountRefusesNoneOfThem— every wrong reason for a refusal is still a refusal. Rmdir ofa directory that does not exist fails; so does Removexattr of an attribute never set. So this asserts
that no operation returns EROFS on a writable mount, which is what makes EROFS mean the flag.
TestEveryFUSEGateFiresOnItsOwn— with both layers armed, deletingFileHandle.Write's gate leavesthe refusal test green, because the backstop answers with the same errno. Two layers that cover each
other's absence are what was wanted at runtime and what makes a mutation invisible. This runs with the
gate armed and the write path writable, so any EROFS came from the gate.
TestTheWriterBackstopHoldsWithoutTheFUSEGate— the mirror: the FUSE gate off, the write pathread-only. It stands for the fourteenth entry point, added later by someone who did not know about the
thirteen.
Mutation-verified, eight mutations, each compiling
ReadOnlyfrombuildMountOptionsTestMountReadOnlyReachesBothEnforcingLayersReadOnlyfrombuildWriterOptionsmutatingNodecheckTestTheWriterBackstopHoldsWithoutTheFUSEGateFileHandle.Write's gateTestEveryFUSEGateFiresOnItsOwnonly — the both-layers test stayed green, exactly as its comment predictsUnlink's gateDELETE--read-onlyoverride armTestApplyCommandLineOverrides— nothing caught this before, which is why the subtest was added--read-only is one-wayroback intokindIgnoreTestTranslatecasesVerification
make test— green, full suite with-racegolangci-lint run ./internal/... ./cmd/...— no finding in any file this PR touches. The 13modernizefindings are pre-existing and come from the local v2.13.2 rather than CI's pinnedv2.12.2.
GOOS=linuxlocally cannot typechecksdks/cat all, since cgo does not cross-compilefrom darwin; that is a local artifact, and CI lints linux natively.