Skip to content

Commit e5a28e1

Browse files
committed
scudo: Fix quarantine allocation when MTE enabled.
Quarantines have always been broken when MTE is enabled because the quarantine batch allocator fails to reset tags that may have been left behind by a user allocation. This was only noticed when running the Scudo unit tests with Scudo as the system allocator because quarantines are turned off by default on Android and the test binary turns them on by defining __scudo_default_options, which affects the system allocator as well. Differential Revision: https://reviews.llvm.org/D92881
1 parent 9f8aeb0 commit e5a28e1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler-rt/lib/scudo/standalone/combined.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ class Allocator {
9898
Header.State = Chunk::State::Allocated;
9999
Chunk::storeHeader(Allocator.Cookie, Ptr, &Header);
100100

101+
// Reset tag to 0 as this chunk may have been previously used for a tagged
102+
// user allocation.
103+
if (UNLIKELY(Allocator.useMemoryTagging()))
104+
storeTags(reinterpret_cast<uptr>(Ptr),
105+
reinterpret_cast<uptr>(Ptr) + sizeof(QuarantineBatch));
106+
101107
return Ptr;
102108
}
103109

0 commit comments

Comments
 (0)