This is an archive of the discontinued LLVM Phabricator instance.

[HWASan] Improve invalid free reports.
Changes PlannedPublic

Authored by hctim on Dec 9 2020, 9:29 AM.

Details

Reviewers
pcc
eugenis
Summary

Improve invalid free reports by checking that the pointer is valid on
free. This is relatively cheap for the primary, but is somewhat
expensive for the secondary as it involves locking.

This patch also fixes up some minor grammatical errors in the existing
reports, namely 'of a X-byte region' instead of 'of X-byte region'.

Diff Detail

Event Timeline

hctim requested review of this revision.Dec 9 2020, 9:29 AM
hctim created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2020, 9:29 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
hctim updated this revision to Diff 310943.Dec 10 2020, 9:41 AM
  • Fix up weird invalid space character.
eugenis added inline comments.Dec 10 2020, 1:17 PM
compiler-rt/lib/hwasan/hwasan_allocator.cpp
184

That's O(live allocations).

compiler-rt/lib/hwasan/hwasan_report.cpp
538

just print "??" instead of the memory tag

hctim planned changes to this revision.Dec 10 2020, 4:01 PM

Offline chat - we're talking about how to identify secondary allocations in a cheaper-than-O(n) way. There's two possibilities, either the secondary maintains a hashset of allocated ptrs (I really don't want to implement this data structure), or we make it stash a cookie that's stored on free(). Probably the latter.