This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Do not use short granule tags as poison tags.
ClosedPublic

Authored by fmayer on Jun 15 2021, 8:30 AM.

Details

Summary

Short granule tags as poison cause a UaF to read the referenced
memory to retrieve the tag, and means we do not detect the UaF
if the last granule's tag is still around.

This only increases the change of not catching a UaF from
0.39 % (1 / 256) to 0.42 % (1 / (256 - 17)).

Diff Detail

Event Timeline

fmayer requested review of this revision.Jun 15 2021, 8:30 AM
fmayer created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2021, 8:30 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
fmayer updated this revision to Diff 352155.Jun 15 2021, 8:34 AM

Static assert for fallback tag.

fmayer edited the summary of this revision. (Show Details)Jun 15 2021, 8:50 AM
fmayer updated this revision to Diff 352204.Jun 15 2021, 11:41 AM

Fix formatting.

eugenis added inline comments.Jun 15 2021, 1:07 PM
compiler-rt/lib/hwasan/hwasan_allocator.cpp
240

I think it would be cleaner and faster to loop until GenerateRandomTag returns something >=kShadowAlignment - that would be just 1 unlikely branch compared to all the stuff GenerateRandomTag does on each call.

Or even pass a minimum tag value as an argument - there is a loop like that inside GenerateRandomTag already.

fmayer updated this revision to Diff 352390.Jun 16 2021, 4:05 AM

Simplify logic.

fmayer marked an inline comment as done.Jun 16 2021, 4:06 AM
This revision is now accepted and ready to land.Jun 16 2021, 10:58 AM
This revision was automatically updated to reflect the committed changes.