This is an archive of the discontinued LLVM Phabricator instance.

scudo: Require fault address to be in bounds for UAF.
ClosedPublic

Authored by pcc on May 12 2021, 3:53 PM.

Details

Summary

The bounds check that we previously had here was suitable for secondary
allocations but not for UAF on primary allocations, where it is likely
to result in false positives. Fix it by using a different bounds check
for UAF that requires the fault address to be in bounds.

Diff Detail

Event Timeline

pcc created this revision.May 12 2021, 3:53 PM
pcc requested review of this revision.May 12 2021, 3:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2021, 3:53 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
eugenis added inline comments.May 12 2021, 4:14 PM
compiler-rt/lib/scudo/standalone/combined.h
1350

getPageSizeCached is an arbitrary threshold for reporting secondary oob, right? That could use a comment. In general, it would be great to list the assumption reporting code makes about the buffer contents - ex. the fact that allocation-without-deallocation entries are only possible for secondary.

pcc added inline comments.May 12 2021, 4:47 PM
compiler-rt/lib/scudo/standalone/combined.h
1350

It's based on the size of the guard region on either side of the allocation, which is guaranteed to be at least a page (guard page on the right, guard page + tagged region on the left). I'll add some comments here.

eugenis added inline comments.May 12 2021, 4:49 PM
compiler-rt/lib/scudo/standalone/combined.h
1350

Ah good point. Since we do not tag secondary allocations, we would not know what to do with anything we find beyond the guard page anyway!

pcc updated this revision to Diff 344984.May 12 2021, 5:03 PM
  • Add comments
pcc marked an inline comment as done.May 12 2021, 5:03 PM
eugenis accepted this revision.May 12 2021, 5:06 PM

LGTM

This revision is now accepted and ready to land.May 12 2021, 5:06 PM
This revision was automatically updated to reflect the committed changes.