This is an archive of the discontinued LLVM Phabricator instance.

[asan] Prevent folding of globals with redzones
ClosedPublic

Authored by vitalybuka on Dec 18 2018, 3:05 PM.

Details

Summary

ICF prevented by removing unnamed_addr and local_unnamed_addr for all sanitized
globals. Also in general unnamed_addr is not valid here as address now is important for
ODR violation detector and redzone poisoning.

ICF on globals causes:

  1. false ODR reports when we register global on the same address more than once
  2. globals buffer overflow if we fold variables of smaller type inside of large

type. Then the smaller one will poison redzone which overlaps with the larger one.

Both can be avoided with private aliases and ODR-indicators, however they
increase size more than just disabling ICF on sanitized globals.

Diff Detail

Event Timeline

vitalybuka created this revision.Dec 18 2018, 3:05 PM
pcc added inline comments.Dec 18 2018, 4:46 PM
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
2151

The comment should say that asan's ODR violation detector and redzone poisoning implicitly creates a dependence on the global's address, so it is no longer valid for it to be marked unnamed_addr.

2203

Can we remove the linkonce_odr and weak_odr checks from here now?

vitalybuka marked an inline comment as done.

updated comment

vitalybuka marked an inline comment as done.Dec 19 2018, 1:00 PM
vitalybuka added inline comments.
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
2203
vitalybuka edited the summary of this revision. (Show Details)Dec 19 2018, 1:00 PM
pcc accepted this revision.Dec 19 2018, 4:31 PM

LGTM

This revision is now accepted and ready to land.Dec 19 2018, 4:31 PM
This revision was automatically updated to reflect the committed changes.