[PATCH] D143637: StackProtector: add unwind cleanup paths for instrumentation.

Tim Northover via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 03:35:23 PST 2023


t.p.northover created this revision.
Herald added subscribers: hiraditya, mcrosier.
Herald added a project: All.
t.p.northover requested review of this revision.
Herald added a project: LLVM.

This is a mitigation patch for https://bugs.chromium.org/p/llvm/issues/detail?id=30, where existing stack protection is skipped if a function is returned through by an unwinder rather than the normal call/return path. The recent patch D139254 <https://reviews.llvm.org/D139254> added the ability to instrument a visible unwind path, at least in the IR case (I'm working on the SelectionDAG instrumentation too) but there are still invisible unwinds it can't reach.

So this patch adds logic to DwarfEHPrepare that goes through a function, converting any `call` that might throw into an invoke to a simple resume cleanup, and adding `cleanup` clauses to existing `landingpad`s that lack them. Obviously we don't really want to do this if it's wasted effort, so I also exposed `requiresStackProtector` from the actual StackProtector code to skip the extra paths if they won't be used.


https://reviews.llvm.org/D143637

Files:
  llvm/include/llvm/CodeGen/StackProtector.h
  llvm/lib/CodeGen/DwarfEHPrepare.cpp
  llvm/lib/CodeGen/StackProtector.cpp
  llvm/test/CodeGen/Generic/safestack-unwind.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143637.496070.patch
Type: text/x-patch
Size: 20239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230209/adfe03b8/attachment.bin>


More information about the llvm-commits mailing list