Preserve TMPDIR for sandbox chroot setup#13269
Open
Haihan-Jiang wants to merge 1 commit into
Open
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 #12476.
The sandbox process clears its environment before running
boot. That keeps the sandbox process from inheriting arbitrary caller environment variables, but it also dropsTMPDIR, soos.TempDir()in the sandbox can resolve to/tmpeven when the parent runsc process was launched with a different host temp directory such as/realtmp. The chroot setup then attempts to mount using the wrong path and can fail on systems where/tmpmust not be used or is a symlink.This change:
TMPDIRwhen the parent process has it set;TEMP,TMP, and other caller variables out of the sandbox environment;TMPDIRexception.Validation:
gofmt -w runsc/sandbox/sandbox.go runsc/sandbox/env_test.go test/root/runsc_test.gogit diff --checkbazel build --nobuild //runsc/sandbox:sandbox_test //test/root:root_testI also attempted
bazel test //runsc/sandbox:sandbox_teston macOS, but this host cannot build the existing eBPF genrules because Linux headers such aslinux/types.hare unavailable.