This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer_common] Create max_allocation_size_mb flag.
ClosedPublic

Authored by morehouse on Oct 29 2019, 11:19 AM.

Details

Summary

The flag allows the user to specify a maximum allocation size that the
sanitizers will honor. Any larger allocations will return nullptr or
crash depending on allocator_may_return_null.

Event Timeline

morehouse created this revision.Oct 29 2019, 11:19 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 29 2019, 11:19 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
eugenis added inline comments.Oct 29 2019, 12:35 PM
compiler-rt/lib/asan/asan_allocator.cpp
288

why not in SharedInitCode ?
why not use Min(, kMaxAllowedMallocSize) same as you do in lsan and msan allocators?

444

Do we need this check as well?
needed_size > max_user_defined_malloc_size

morehouse marked 2 inline comments as done.Oct 29 2019, 12:49 PM
morehouse added inline comments.
compiler-rt/lib/asan/asan_allocator.cpp
288

why not in SharedInitCode ?

SharedInitCode is also called from ReInitialize, which I think is redundant, since the common_flags wouldn't have changed (right?).

why not use Min(, kMaxAllowedMallocSize) same as you do in lsan and msan allocators?

I'm not sure we want to include ASan metadata in this new limit, while we do include it for the check against kMaxAllowedMallocSize.

444

I *think* we only want to check size here, but I'm not sure. @kcc Does Mozilla care about ASan metadata and alignment padding for this limit?

eugenis accepted this revision.Oct 29 2019, 1:11 PM

LGTM

compiler-rt/lib/asan/asan_allocator.cpp
444

Makes sense.

This revision is now accepted and ready to land.Oct 29 2019, 1:11 PM
kcc accepted this revision.Oct 30 2019, 10:12 AM

LGTM, thanks!

This revision was automatically updated to reflect the committed changes.