Skip to content

Commit 64820bd

Browse files
committed
Proper sandbox
1 parent 26abcee commit 64820bd

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define LLVM_CODEGEN_ASMPRINTER_H
1717

1818
#include "llvm/ADT/DenseMap.h"
19-
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2019
#include "llvm/ADT/MapVector.h"
2120
#include "llvm/ADT/SmallSet.h"
2221
#include "llvm/ADT/SmallVector.h"
@@ -88,10 +87,6 @@ namespace remarks {
8887
class RemarkStreamer;
8988
}
9089

91-
namespace vfs {
92-
class FileSystem;
93-
}
94-
9590
/// This class is intended to be used as a driving class for all asm writers.
9691
class LLVM_ABI AsmPrinter : public MachineFunctionPass {
9792
public:

llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "llvm/MC/MCSymbol.h"
3535
#include "llvm/MC/TargetRegistry.h"
3636
#include "llvm/Support/ErrorHandling.h"
37+
#include "llvm/Support/IOSandbox.h"
3738
#include "llvm/Support/MemoryBuffer.h"
3839
#include "llvm/Support/SourceMgr.h"
3940
#include "llvm/Support/VirtualFileSystem.h"
@@ -98,13 +99,12 @@ void AsmPrinter::emitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
9899

99100
unsigned BufNum = addInlineAsmDiagBuffer(Str, LocMDNode);
100101
SourceMgr &SrcMgr = *MMI->getContext().getInlineSourceManager();
101-
// FIXME(sandboxing): This is not executed in tests, but might be common.
102-
// Propagating vfs::FileSystem here is lots of work,
103-
// consider bypassing the sandbox.
104-
if (!MCOptions.IASSearchPaths.empty()) {
105-
SrcMgr.setIncludeDirs(MCOptions.IASSearchPaths);
106-
SrcMgr.setVirtualFileSystem(vfs::getRealFileSystem());
107-
}
102+
SrcMgr.setIncludeDirs(MCOptions.IASSearchPaths);
103+
SrcMgr.setVirtualFileSystem([] {
104+
// FIXME(sandboxing): Propagating vfs::FileSystem here is lots of work.
105+
[[maybe_unused]] auto BypassSandbox = sys::sandbox::scopedDisable();
106+
return vfs::getRealFileSystem();
107+
}());
108108

109109
std::unique_ptr<MCAsmParser> Parser(
110110
createMCAsmParser(SrcMgr, OutContext, *OutStreamer, *MAI, BufNum));

0 commit comments

Comments
 (0)