[scudo] Untag BlockEnd in reallocate

If we get here from reallocate, BlockEnd is tagged. Then we
will storeTag(UntaggedEnd) into the header of the next chunk.

Luckily header tag is 0 so unpatched code still works.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D105261
This commit is contained in:
Vitaly Buka 2021-06-30 20:22:41 -07:00
parent e386871e1d
commit fe30963600
1 changed files with 2 additions and 1 deletions

View File

@ -639,7 +639,7 @@ public:
if (ClassId) {
resizeTaggedChunk(reinterpret_cast<uptr>(OldTaggedPtr) + OldSize,
reinterpret_cast<uptr>(OldTaggedPtr) + NewSize,
NewSize, BlockEnd);
NewSize, untagPointer(BlockEnd));
storePrimaryAllocationStackMaybe(Options, OldPtr);
} else {
storeSecondaryAllocationStackMaybe(Options, OldPtr, NewSize);
@ -1154,6 +1154,7 @@ private:
// address tags against chunks. To allow matching in this case we store the
// address tag in the first byte of the chunk.
void storeEndMarker(uptr End, uptr Size, uptr BlockEnd) {
DCHECK_EQ(BlockEnd, untagPointer(BlockEnd));
uptr UntaggedEnd = untagPointer(End);
if (UntaggedEnd != BlockEnd) {
storeTag(UntaggedEnd);