[PATCH] D104266: [DFSan] Handle landingpad inst explicitly as zero shadow.

Andrew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 14:35:00 PDT 2021


browneee created this revision.
browneee added a reviewer: stephan.yichao.zhao.
Herald added a subscriber: hiraditya.
browneee requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Before this change, DFSan was relying fallback cases when getting origin
address.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104266

Files:
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/call.ll


Index: llvm/test/Instrumentation/DataFlowSanitizer/call.ll
===================================================================
--- llvm/test/Instrumentation/DataFlowSanitizer/call.ll
+++ llvm/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -48,7 +48,7 @@
           catch i8* null
   %1 = extractvalue { i8*, i32 } %0, 0
 
-  ; CHECK: store {{.*}} @__dfsan_arg_tls
+  ; CHECK: store i8 0,{{.*}} @__dfsan_arg_tls
   ; CHECK: call {{.*}} @"dfs$__cxa_begin_catch"
   ; CHECK: load {{.*}} @__dfsan_retval_tls
   %2 = tail call i8* @__cxa_begin_catch(i8* %1)
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -721,6 +721,7 @@
   void visitBitCastInst(BitCastInst &BCI);
   void visitCastInst(CastInst &CI);
   void visitCmpInst(CmpInst &CI);
+  void visitLandingPadInst(LandingPadInst &LPI);
   void visitGetElementPtrInst(GetElementPtrInst &GEPI);
   void visitLoadInst(LoadInst &LI);
   void visitStoreInst(StoreInst &SI);
@@ -2561,6 +2562,13 @@
   }
 }
 
+void DFSanVisitor::visitLandingPadInst(LandingPadInst &LPI) {
+  // Do nothing.
+  // See https://github.com/google/sanitizers/issues/504
+  DFSF.setShadow(&LPI, DFSF.DFS.getZeroShadow(&LPI));
+  DFSF.setOrigin(&LPI, DFSF.DFS.ZeroOrigin);
+}
+
 void DFSanVisitor::visitGetElementPtrInst(GetElementPtrInst &GEPI) {
   if (ClCombineOffsetLabelsOnGEP) {
     visitInstOperands(GEPI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104266.351999.patch
Type: text/x-patch
Size: 1547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210614/8e8b4dbc/attachment.bin>


More information about the llvm-commits mailing list