This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Check for pvalloc overflow
ClosedPublic

Authored by cryptoad on Jul 24 2017, 3:04 PM.

Details

Summary

Previously we were rounding up the size passed to pvalloc to the next
multiple of page size no matter what. There is an overflow possibility that
wasn't accounted for. So now, return null in the event of an overflow. The man
page doesn't seem to indicate the errno to set in this particular situation,
but the glibc unit tests go for ENOMEM (https://code.woboq.org/userspace/glibc/malloc/tst-pvalloc.c.html#54)
so we'll do the same.
Update the aligned allocation funtions tests to check for properly aligned
returned pointers, and the pvalloc corner cases.

@alekseyshl: do you want me to do the same in the other Sanitizers?

Event Timeline

cryptoad created this revision.Jul 24 2017, 3:04 PM
alekseyshl accepted this revision.Jul 24 2017, 5:05 PM

Yep, please do it other sanitizers too. Seems like a reasonable change.

test/scudo/memalign.cpp
80

Spaces around -

84

Ditto

This revision is now accepted and ready to land.Jul 24 2017, 5:05 PM

Do you prefer the other sanitizers in the same CL or a different one?

test/scudo/memalign.cpp
80

Just making sure: do you want spaces around the unary minus? I feel it's usually not the case.

Let's have a cl per sanitizer.

test/scudo/memalign.cpp
80

Silly me :) ignore both

cryptoad updated this revision to Diff 108104.Jul 25 2017, 9:41 AM

Move valloc & pvalloc tests to their own file.

cryptoad requested review of this revision.Jul 25 2017, 10:01 AM
cryptoad edited edge metadata.
alekseyshl accepted this revision.Jul 25 2017, 1:52 PM
This revision is now accepted and ready to land.Jul 25 2017, 1:52 PM
cryptoad closed this revision.Jul 25 2017, 2:18 PM