This is an archive of the discontinued LLVM Phabricator instance.

[HWASan] Allow no_sanitize(..) and change metadata passing.
AbandonedPublic

Authored by hctim on Feb 9 2022, 12:41 PM.

Details

Summary

Currently HWASan uses the no_sanitize shared with llvm.asan.globals to
disable hwasanification. The llvm.asan.globals list contains a whole
bunch of fluff (location, name, dynamically-initialized, excluded) in
order for dynamic initialization in ASan. We don't do that in HWASan,
globals have a static tag that's embedded in the file.

Right now, it's not possible for no_sanitize("hwaddress") to be slapped
on a global. Add this feature.

In addition, add the metadata to the global variable itself, as to
whether sanitization is disabled. Passes like GlobalOpt can replace the
existing global, and only copies the metadata for the GlobalVariable
itself, without replacing the GV pointers in llvm.asan.globals. This can
cause bugs, where no_sanitize("hwaddress") (and "address" as well, but
that's left for another time) ends up getting ignored if the global is
replaced.

Diff Detail

Event Timeline

hctim created this revision.Feb 9 2022, 12:41 PM
hctim requested review of this revision.Feb 9 2022, 12:41 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptFeb 9 2022, 12:41 PM
Herald added subscribers: llvm-commits, Restricted Project, cfe-commits. · View Herald Transcript

You might want to update Bitcode writer/reader as well, otherwise nosanitize will be lost after a trip through .bc/.ii.

compiler-rt/test/hwasan/TestCases/global-with-reduction.c
50

did you mean to do it twice?

pcc added a comment.Feb 11 2022, 12:00 PM

In addition to the .bc support we will also need support for reading/writing .ll files.

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

Looks like you'll need to update llvm/test/Instrumentation/HWAddressSanitizer/globals.ll to use the new attribute instead (after adding the .ll support).

hctim abandoned this revision.Jun 10 2022, 4:53 PM

Deprecated by D127544.

Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 4:53 PM
Herald added a subscriber: Enna1. · View Herald Transcript