Skip to content

Conversation

@jansvoboda11
Copy link
Contributor

Based on the name of the function, I think it's safe to assume sys::fs::createTemporaryFile() is not to be used for formal compiler outputs and should only be used for compiler-internal outputs (caches, debugging output, etc.). Thus, it should be fine to disable the IO sandbox and allow bypassing vfs::OutputBackend here.

@llvmbot
Copy link
Member

llvmbot commented Jan 5, 2026

@llvm/pr-subscribers-llvm-support

Author: Jan Svoboda (jansvoboda11)

Changes

Based on the name of the function, I think it's safe to assume sys::fs::createTemporaryFile() is not to be used for formal compiler outputs and should only be used for compiler-internal outputs (caches, debugging output, etc.). Thus, it should be fine to disable the IO sandbox and allow bypassing vfs::OutputBackend here.


Full diff: https://github.com/llvm/llvm-project/pull/174491.diff

1 Files Affected:

  • (modified) llvm/lib/Support/Path.cpp (+4)
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp
index 3f7e002915895..1e2d53196e923 100644
--- a/llvm/lib/Support/Path.cpp
+++ b/llvm/lib/Support/Path.cpp
@@ -894,6 +894,10 @@ static std::error_code
 createTemporaryFile(const Twine &Model, int &ResultFD,
                     llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type,
                     sys::fs::OpenFlags Flags = sys::fs::OF_None) {
+  // Any *temporary* file is assumed to be a compiler-internal output, not
+  // a formal one.
+  auto BypassSandbox = sys::sandbox::scopedDisable();
+
   SmallString<128> Storage;
   StringRef P = Model.toNullTerminatedStringRef(Storage);
   assert(P.find_first_of(separators(Style::native)) == StringRef::npos &&

@jansvoboda11 jansvoboda11 merged commit a165f8c into llvm:main Jan 6, 2026
12 checks passed
@jansvoboda11 jansvoboda11 deleted the create-temp-file-sandbox branch January 6, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants