Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/lib/CAS/OnDiskGraphDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/IOSandbox.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
Expand Down Expand Up @@ -1226,6 +1227,8 @@ OnDiskGraphDB::load(ObjectID ExternalRef) {
SmallString<256> Path;
getStandalonePath(TrieRecord::getStandaloneFilePrefix(Object.SK), *I, Path);

auto BypassSandbox = sys::sandbox::scopedDisable();

auto File = sys::fs::openNativeFileForRead(Path);
if (!File)
return createFileError(Path, File.takeError());
Expand Down Expand Up @@ -1329,6 +1332,8 @@ OnDiskContent StandaloneDataInMemory::getContent() const {

static Expected<MappedTempFile> createTempFile(StringRef FinalPath,
uint64_t Size) {
auto BypassSandbox = sys::sandbox::scopedDisable();

assert(Size && "Unexpected request for an empty temp file");
Expected<TempFile> File = TempFile::create(FinalPath + ".%%%%%%");
if (!File)
Expand Down Expand Up @@ -1366,6 +1371,8 @@ Error OnDiskGraphDB::createStandaloneLeaf(IndexProxy &I, ArrayRef<char> Data) {
int64_t FileSize = Data.size() + Leaf0;
getStandalonePath(TrieRecord::getStandaloneFilePrefix(SK), I, Path);

auto BypassSandbox = sys::sandbox::scopedDisable();

// Write the file. Don't reuse this mapped_file_region, which is read/write.
// Let load() pull up one that's read-only.
Expected<MappedTempFile> File = createTempFile(Path, FileSize);
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/CAS/UnifiedOnDiskCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/IOSandbox.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
Expand Down Expand Up @@ -390,6 +391,8 @@ Expected<std::unique_ptr<UnifiedOnDiskCache>>
UnifiedOnDiskCache::open(StringRef RootPath, std::optional<uint64_t> SizeLimit,
StringRef HashName, unsigned HashByteSize,
OnDiskGraphDB::FaultInPolicy FaultInPolicy) {
auto BypassSandbox = sys::sandbox::scopedDisable();

if (std::error_code EC = sys::fs::create_directories(RootPath))
return createFileError(RootPath, EC);

Expand Down Expand Up @@ -512,6 +515,8 @@ bool UnifiedOnDiskCache::hasExceededSizeLimit() const {
}

Error UnifiedOnDiskCache::close(bool CheckSizeLimit) {
auto BypassSandbox = sys::sandbox::scopedDisable();

if (LockFD == -1)
return Error::success(); // already closed.
auto CloseLock = make_scope_exit([&]() {
Expand Down