Repository navigation
fix(fs): fix FIFO hangs, overlay copy-up, and handle and mode bugs - #870
Merged
Merged
Conversation
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.
Fixes the
fs/findings from the security and bug review against 83b31f1.What changed
FIFOs no longer hang past timeout or cancel
Runtime.RunwithTimeoutnow returns 124 formkfifo /tmp/p; echo hi > /tmp/p, and cancel returns 130.O_NONBLOCK(newfs/host_open_posix.go). Host FIFOs get a handle whose open, reads and writes wait in 20ms polls and stop when the context ends. A writer's open still waits for a reader, asopen(2)would. Host devices, sockets and other special files are refused with EPERM.OverlayFS copy-up
--max-file-bytescan now be overwritten, truncated, chmodded, chowned, linked and renamed. Reading or appending to it still fails withEFBIG, the same as on the lower layer.O_CREATE,Symlink,Link,Mkfifo,MkdirAll,Rename) first copies up lower parent directories with their mode, owner and mtime, as SPEC §10 requires. Before this,touch sub/newturned a hostsubwith mode 700 into 755.Renamemoves nodes that are already in the upper layer instead of copying them, so hard links and lazily copied files survive the move.lowerDirscache is still trusted for whether a path prefix is a directory. That assumption is now written in the code and SPEC, and directory metadata copied up is always re-read from the lower layer.MemoryFS / TrieFS
exec 3>a; mv a b; echo hi >&3now writes tob, andexec 4<c; rm c; echo new > c; cat <&4reads the old content.MkdirAll(p, ModeSymlink|0755)(reachable from nodejsfs.mkdirSync) created corrupt dir+symlink nodes that could not be deleted.Rename("/a","/a/x/y")no longer leaves/a/xbehind. Chmod keeps setuid, setgid and sticky.Reviewer notes
newMemoryFIFOFilenow takesctxas its first argument.fs/, the only additions are two new test files:internal/runtime/fifo_timeout_test.goandinternal/runtime/open_fd_binding_test.go.examples/internal/agentfsfs/fifo.gohas its own copy of the FIFO code with the same hang. It is not changed here.Testing
make lint: clean.go test ./fs/... ./internal/runtime/passes, andgo test -race ./fs/passes.make buildpasses.go vetbut not run.go test ./...also shows these failures, which are pre-existing or environmental:scripts/bench-compareand the timing-sensitiveTestRunCLIHostUtilityTail*tests also fail on the base commit.CLI check of the repros: