[PATCH] D109386: Fix use-after-free from GlobalCtors associated data
Lei Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 8 14:50:25 PDT 2021
wlei updated this revision to Diff 371455.
wlei added a comment.
change to use ValueHandle for associated data
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109386/new/
https://reviews.llvm.org/D109386
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
Index: clang/lib/CodeGen/CodeGenModule.h
===================================================================
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -294,7 +294,7 @@
AssociatedData(AssociatedData) {}
int Priority;
llvm::Constant *Initializer;
- llvm::Constant *AssociatedData;
+ llvm::WeakTrackingVH AssociatedData;
};
typedef std::vector<Structor> CtorList;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1463,7 +1463,8 @@
ctor.addInt(Int32Ty, I.Priority);
ctor.add(llvm::ConstantExpr::getBitCast(I.Initializer, CtorPFTy));
if (I.AssociatedData)
- ctor.add(llvm::ConstantExpr::getBitCast(I.AssociatedData, VoidPtrTy));
+ ctor.add(llvm::ConstantExpr::getBitCast(
+ cast<llvm::Constant>(I.AssociatedData), VoidPtrTy));
else
ctor.addNullPointer(VoidPtrTy);
ctor.finishAndAddTo(ctors);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109386.371455.patch
Type: text/x-patch
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210908/e5b13342/attachment.bin>
More information about the cfe-commits
mailing list