This is an archive of the discontinued LLVM Phabricator instance.

hwasan: Emit the globals note even when globals are uninstrumented.
ClosedPublic

Authored by pcc on Aug 12 2020, 8:25 PM.

Details

Summary

This lets us support the scenario where a binary is linked from a mix
of object files with both instrumented and non-instrumented globals.
This is likely to occur on Android where the decision of whether to use
instrumented globals is based on the API level, which is user-facing.

Previously, in this scenario, it was possible for the comdat from
one of the object files with non-instrumented globals to be selected,
and since this comdat did not contain the note it would mean that the
note would be missing in the linked binary and the globals' shadow
memory would be left uninitialized, leading to a tag mismatch failure
at runtime when accessing one of the instrumented globals.

It is harmless to include the note when targeting a runtime that does
not support instrumenting globals because it will just be ignored.

Diff Detail

Event Timeline

pcc created this revision.Aug 12 2020, 8:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 8:25 PM
pcc requested review of this revision.Aug 12 2020, 8:25 PM
eugenis accepted this revision.Aug 13 2020, 1:49 PM

LGTM

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
369

It's hard to review like this, but I presume this code was moved from instrumentGlobals verbatim?

This revision is now accepted and ready to land.Aug 13 2020, 1:49 PM
pcc added inline comments.Aug 13 2020, 4:31 PM
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
369

Yes, aside from a new paragraph added to the long comment below. Phabricator subtly indicates that the code was moved with the yellow highlight along the left hand side of the code.

This revision was landed with ongoing or failed builds.Aug 13 2020, 4:33 PM
This revision was automatically updated to reflect the committed changes.