This is an archive of the discontinued LLVM Phabricator instance.

[asan] Add support for disable_sanitizer_instrumentation attribute
ClosedPublic

Authored by glider on Nov 23 2021, 1:35 AM.

Details

Summary

For ASan this will effectively serve as a synonym for
attribute((no_sanitize("address")))

Diff Detail

Event Timeline

glider requested review of this revision.Nov 23 2021, 1:35 AM
glider created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 1:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
melver accepted this revision.Nov 23 2021, 2:52 AM

Thanks!

This revision is now accepted and ready to land.Nov 23 2021, 2:52 AM

Vitaly, Evgenii, can one of you please take a look?

glider added a comment.Dec 2 2021, 3:23 AM

Given this is a minor change that only affects users of disable_sanitizer_instrumentation, I'm inclined towards landing it.

eugenis accepted this revision.Dec 2 2021, 2:12 PM

LGTM

clang/test/CodeGen/asan-globals.cpp
61

Does this test rely on the metadata being in the same order as the global declarations in the source? Feels brittle and hard to understand - could you check if the regexps could be made more precise?

vitalybuka accepted this revision.Dec 2 2021, 11:52 PM

Should we have in AddressSanitizer.cpp the following for consistency with other sanitizers?
if (F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))

return false;
glider updated this revision to Diff 392382.Dec 7 2021, 6:52 AM

Addressed the comments

Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2021, 6:52 AM
glider updated this revision to Diff 392389.Dec 7 2021, 7:09 AM

Updated asan-globals.cpp

glider added a comment.Dec 7 2021, 7:14 AM

Should we have in AddressSanitizer.cpp the following for consistency with other sanitizers?

Good catch, without that disable_sanitizer_instrumentation could not override sanitize_address.
I fixed this and added a test.

clang/test/CodeGen/asan-globals.cpp
61

llvm.asan.globals above actually look as follows: !llvm.asan.globals = !{!0, !2, !4, !6, !7, !8, !9, !11, !13, !15}

, so the placeholder variables (e.g. ATTR_GLOBAL and DISABLE_INSTR_GLOBAL) actually match just the metadata node numbers.
I replaced the {{.*}} with variable/file names where applicable, but we'll still depend on the order of globals.

glider updated this revision to Diff 393168.Dec 9 2021, 7:56 AM

Rebase.

I think we dropped the ball on this - was it ever re-reverted?
Is it still worth trying to land this?