This is an archive of the discontinued LLVM Phabricator instance.

[BoundsChecking] Fix merging of sizes
ClosedPublic

Authored by aeubanks on Aug 2 2022, 10:55 AM.

Details

Summary

BoundsChecking uses ObjectSizeOffsetEvaluator to keep track of the
underlying size/offset of pointers in allocations. However,
ObjectSizeOffsetVisitor (something ObjectSizeOffsetEvaluator
uses to check for constant sizes/offsets)
doesn't quite treat sizes and offsets the same way as
BoundsChecking. BoundsChecking wants to know the size of the
underlying allocation and the current pointer's offset within
it, but ObjectSizeOffsetVisitor only cares about the size
from the pointer to the end of the underlying allocation.

This only comes up when merging two size/offset pairs. Add a new mode to
ObjectSizeOffsetVisitor which cares about the underlying size/offset
rather than the size from the current pointer to the end of the
allocation.

Fixes a false positive with -fsanitize=bounds.

Diff Detail

Event Timeline

aeubanks created this revision.Aug 2 2022, 10:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2022, 10:55 AM
aeubanks requested review of this revision.Aug 2 2022, 10:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2022, 10:55 AM
asbirlea accepted this revision.Aug 3 2022, 3:54 PM
This revision is now accepted and ready to land.Aug 3 2022, 3:54 PM
vitalybuka accepted this revision.Aug 3 2022, 4:59 PM
vitalybuka added inline comments.
llvm/lib/Analysis/MemoryBuiltins.cpp
1006
1006

or even

aeubanks added inline comments.Aug 3 2022, 5:21 PM
llvm/lib/Analysis/MemoryBuiltins.cpp
1006

derp, I even had that at some point

This revision was landed with ongoing or failed builds.Aug 3 2022, 5:21 PM
This revision was automatically updated to reflect the committed changes.