[llvm][clang] Sandbox filesystem reads#165350
Conversation
b062e35 to
8e49476
Compare
| } | ||
|
|
||
| std::error_code is_other(const Twine &Path, bool &Result) { | ||
| sandbox::violationIfEnabled(); |
There was a problem hiding this comment.
Won't we catch these via status being a violation? Similarly for the other APIs here (e.g. openFileForRead).
There was a problem hiding this comment.
Yes, but I wanted to explicitly mark each API we expect to cause a sandbox violation. This is still conceptually an API that's required to touch the real FS. If the implementation ever changes from calling sys::fs::status() to calling status() directly, I still want this to remain a violation. Same goes for the other APIs.
There was a problem hiding this comment.
It seems hard to be completely safe against any possible future change like that. For example, there are a bunch of inline functions in FileSystem.h that could theoretically be refactored in the future without remembering to trigger a violation (most of them call a non-inline version that you have a sandbox call in, some call fs::status directly).
There was a problem hiding this comment.
That's true, my approach isn't bulletproof either. Would you prefer if we only triggered sandbox violations the core low-level functions and left stuff like is_other() alone? I don't have a strong preference here.
There was a problem hiding this comment.
That's my weak preference, but I won't block the PR over this if anyone disagrees. It is a (tiny) perf win to only check it once, but I doubt it matters.
benlangmuir
left a comment
There was a problem hiding this comment.
LGTM other than changing the default value of LLVM_ENABLE_IO_SANDBOX.
3a5a95c to
7c3ba74
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/20216 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/110/builds/6756 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/17937 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/19412 Here is the relevant piece of the build log for the reference |
Reverts #171935. The sandbox infrastructure was (incorrectly) only implemented for `clang -cc1` jobs created by the driver in #165350. Direct `clang -cc1` invocations had the sandbox disabled. This reduced the coverage of our test suite and lead to sandbox violations for people using asserts-enabled Clang. This PR temporarily disables the sandbox for asserts builds, so that we have time to investigate and fix sandbox violations for direct `clang -cc1` commands and re-enable for asserts builds at a later time.
… (#173074) Reverts llvm/llvm-project#171935. The sandbox infrastructure was (incorrectly) only implemented for `clang -cc1` jobs created by the driver in llvm/llvm-project#165350. Direct `clang -cc1` invocations had the sandbox disabled. This reduced the coverage of our test suite and lead to sandbox violations for people using asserts-enabled Clang. This PR temporarily disables the sandbox for asserts builds, so that we have time to investigate and fix sandbox violations for direct `clang -cc1` commands and re-enable for asserts builds at a later time.
This PR introduces a new mechanism for enforcing a sandbox around filesystem reads coming from the compiler. A fatal error is raised whenever the `llvm::sys::fs`, `llvm::MemoryBuffer::getFile*()` APIs get used directly instead of going through the "blessed" virtual interface of `llvm::vfs::FileSystem`.
Reverts llvm#171935. The sandbox infrastructure was (incorrectly) only implemented for `clang -cc1` jobs created by the driver in llvm#165350. Direct `clang -cc1` invocations had the sandbox disabled. This reduced the coverage of our test suite and lead to sandbox violations for people using asserts-enabled Clang. This PR temporarily disables the sandbox for asserts builds, so that we have time to investigate and fix sandbox violations for direct `clang -cc1` commands and re-enable for asserts builds at a later time.
Reverts llvm#171935. The sandbox infrastructure was (incorrectly) only implemented for `clang -cc1` jobs created by the driver in llvm#165350. Direct `clang -cc1` invocations had the sandbox disabled. This reduced the coverage of our test suite and lead to sandbox violations for people using asserts-enabled Clang. This PR temporarily disables the sandbox for asserts builds, so that we have time to investigate and fix sandbox violations for direct `clang -cc1` commands and re-enable for asserts builds at a later time.
This PR enables the FS sandbox for direct `clang -cc1` invocations. #165350 unintentionally implemented the sandbox only for the code path where `clang -cc1` gets invoked after being expanded from a driver command line, which reduced the expected test coverage.
…ns (#174653) This PR enables the FS sandbox for direct `clang -cc1` invocations. llvm/llvm-project#165350 unintentionally implemented the sandbox only for the code path where `clang -cc1` gets invoked after being expanded from a driver command line, which reduced the expected test coverage.
This PR enables the FS sandbox for direct `clang -cc1` invocations. llvm/llvm-project#165350 unintentionally implemented the sandbox only for the code path where `clang -cc1` gets invoked after being expanded from a driver command line, which reduced the expected test coverage.
…4653) This PR enables the FS sandbox for direct `clang -cc1` invocations. llvm#165350 unintentionally implemented the sandbox only for the code path where `clang -cc1` gets invoked after being expanded from a driver command line, which reduced the expected test coverage.
Reverts llvm/llvm-project#171935. The sandbox infrastructure was (incorrectly) only implemented for `clang -cc1` jobs created by the driver in llvm/llvm-project#165350. Direct `clang -cc1` invocations had the sandbox disabled. This reduced the coverage of our test suite and lead to sandbox violations for people using asserts-enabled Clang. This PR temporarily disables the sandbox for asserts builds, so that we have time to investigate and fix sandbox violations for direct `clang -cc1` commands and re-enable for asserts builds at a later time. (cherry picked from commit 56c0173)
This PR enables the FS sandbox for direct `clang -cc1` invocations. llvm/llvm-project#165350 unintentionally implemented the sandbox only for the code path where `clang -cc1` gets invoked after being expanded from a driver command line, which reduced the expected test coverage. (cherry picked from commit 3911c6a)
…4653) This PR enables the FS sandbox for direct `clang -cc1` invocations. llvm#165350 unintentionally implemented the sandbox only for the code path where `clang -cc1` gets invoked after being expanded from a driver command line, which reduced the expected test coverage.
This PR introduces a new mechanism for enforcing a sandbox around filesystem reads coming from the compiler. A fatal error is raised whenever the
llvm::sys::fs,llvm::MemoryBuffer::getFile*()APIs get used directly instead of going through the "blessed" virtual interface ofllvm::vfs::FileSystem.