This is an archive of the discontinued LLVM Phabricator instance.

[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0
ClosedPublic

Authored by kstoimenov on Feb 6 2023, 3:17 PM.

Diff Detail

Event Timeline

kstoimenov created this revision.Feb 6 2023, 3:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2023, 3:17 PM
Herald added a subscriber: Enna1. · View Herald Transcript
kstoimenov requested review of this revision.Feb 6 2023, 3:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2023, 3:17 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
MaskRay added a subscriber: MaskRay.Feb 6 2023, 3:32 PM

An alternative is to do if (orig_size == 0) orig_size = 1 in HwasanAllocate. asan/lsan do this.

kstoimenov updated this revision to Diff 495300.Feb 6 2023, 3:42 PM

Make size 1 if 0.

kstoimenov updated this revision to Diff 495302.Feb 6 2023, 3:43 PM

Revert chang in Metadata::IsAllocated.

MaskRay accepted this revision.Feb 6 2023, 3:45 PM

I know that hwasan x86-64 needs involved setup. Wish that is documented somewhere (e.g. https://github.com/google/sanitizers/wiki) so that interested folks (like I) can play with it :)

This revision is now accepted and ready to land.Feb 6 2023, 3:45 PM
kstoimenov updated this revision to Diff 495303.Feb 6 2023, 3:45 PM

Reverted test.

An alternative is to do if (orig_size == 0) orig_size = 1 in HwasanAllocate. asan/lsan do this.

Good point. I changed that to make it consistent with ASAN and LSAN.

vitalybuka accepted this revision.Feb 6 2023, 3:47 PM
This revision was landed with ongoing or failed builds.Feb 6 2023, 3:48 PM
This revision was automatically updated to reflect the committed changes.
vitalybuka added inline comments.Feb 6 2023, 3:48 PM
compiler-rt/lib/hwasan/hwasan_allocator.cpp
166 ↗(On Diff #495303)
168 ↗(On Diff #495303)

same

kstoimenov reopened this revision.Feb 6 2023, 3:51 PM
This revision is now accepted and ready to land.Feb 6 2023, 3:51 PM
kstoimenov retitled this revision from [HWASAN] Fix Metadata::IsAllocatedMetadata::IsAllocated to return true even if the requested size is 0. to [HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0.Feb 6 2023, 3:53 PM
kstoimenov edited the summary of this revision. (Show Details)
kstoimenov updated this revision to Diff 495308.Feb 6 2023, 3:54 PM

Updated title and added UNLIKELY.

This revision was landed with ongoing or failed builds.Feb 6 2023, 4:01 PM
This revision was automatically updated to reflect the committed changes.
kstoimenov reopened this revision.Feb 6 2023, 4:34 PM

Need to fix 2 tests that this patch broke.

This revision is now accepted and ready to land.Feb 6 2023, 4:34 PM