This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Lay the foundation for 32-bit support
ClosedPublic

Authored by cryptoad on Oct 17 2016, 11:52 AM.

Details

Summary

In order to support 32-bit platforms, we have to make some adjustments in
multiple locations, one of them being the Scudo chunk header. For it to fit on
64 bits (as a reminder, on x64 it's 128 bits), I had to crunch the space taken
by some of the fields. In order to keep the offset field small, the secondary
allocator was changed to accomodate aligned allocations for larger alignments,
hence making the offset constant for chunks serviced by it.

The resulting header candidate has been added, and further modifications to
allow 32-bit support will follow.

Another notable change is the addition of MaybeStartBackgroudThread() to allow
release of the memory to the OS.

Event Timeline

cryptoad updated this revision to Diff 74878.Oct 17 2016, 11:52 AM
cryptoad retitled this revision from to [scudo] Lay the foundation for 32-bit support.
cryptoad updated this object.
cryptoad added a subscriber: llvm-commits.
kcc edited edge metadata.Oct 17 2016, 4:23 PM

You do remember that the sanitizer allocators are different between 32- and 64-bit, right?
And the 32-bit one is much less tuned.

Yes, I had a look at all that was required for 32-bit and it doesn't look like an overwhelming amount of work.
I think here is a need for a 32-bit allocator that could help make exploitation of heap bugs harder, particularly on ARM.
So I am willing to give it a shot if that could help Scudo end up on a lot of devices :)
Hopes and dreams aside, laying the foundation for more architecture might be useful for potential consumers.

kcc accepted this revision.Oct 25 2016, 2:40 PM
kcc edited edge metadata.

LGTM with one nit

Also remember that for 32-bit you will need to use the 32-bit primary allocator, which does not have all of improvements we've made in the 64-bit one.

lib/scudo/scudo_allocator.h
66

just "u64"

This revision is now accepted and ready to land.Oct 25 2016, 2:40 PM
cryptoad updated this revision to Diff 75805.Oct 25 2016, 3:32 PM
cryptoad edited edge metadata.

Addressing kcc@ comment, removing unsigned where it is unnecessary.

cryptoad closed this revision.Oct 26 2016, 9:26 AM
cryptoad marked an inline comment as done.