This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Delay adjustment of pointer to prevent referencing invalid memory.
ClosedPublic

Authored by EricWF on Nov 20 2014, 10:14 PM.

Details

Summary

This patch delays the dereference adjustment until we are sure the thrown type is a pointer type. It is possible the thrown type is not a pointer and is smaller than sizeof(void*). If the thrown type is is smaller than sizeof(void*) the deference adjustment will result in a heap buffer overflow.

I audited all the call sites of can_catch(...) and there are no places where adjustedPtr is used if can_catch(...) returns false. For this reason the patch should not introduce any functionality change.

This patch fixes the following tests when using ASAN:

  • unwind_01.cpp
  • unwind_02.cpp
  • unwind_04.cpp

Diff Detail

Event Timeline

EricWF updated this revision to Diff 16472.Nov 20 2014, 10:14 PM
EricWF retitled this revision from to [libcxxabi] Delay adjustment of pointer to prevent referencing invalid memory..
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added reviewers: mclow.lists, danalbert, jroelofs.
EricWF added a subscriber: Unknown Object (MLST).
EricWF updated this object.Nov 21 2014, 1:14 AM
mclow.lists accepted this revision.Nov 24 2014, 8:26 AM
mclow.lists edited edge metadata.

LGTM

This revision is now accepted and ready to land.Nov 24 2014, 8:26 AM
EricWF closed this revision.Nov 24 2014, 10:46 AM