File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
compiler-rt/lib/scudo/standalone Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -785,6 +785,9 @@ class Allocator {
785785 // A corrupted chunk will not be reported as owned, which is WAI.
786786 bool isOwned (const void *Ptr) {
787787 initThreadMaybe ();
788+ // If the allocation is not owned, the tags could be wrong.
789+ ScopedDisableMemoryTagChecks x (
790+ useMemoryTagging<AllocatorConfig>(Primary.Options .load ()));
788791#ifdef GWP_ASAN_HOOKS
789792 if (GuardedAlloc.pointerIsMine (Ptr))
790793 return true ;
Original file line number Diff line number Diff line change @@ -122,9 +122,12 @@ inline NORETURN void enableSystemMemoryTaggingTestOnly() {
122122
123123class ScopedDisableMemoryTagChecks {
124124 uptr PrevTCO;
125+ bool active;
125126
126127public:
127- ScopedDisableMemoryTagChecks () {
128+ ScopedDisableMemoryTagChecks (bool cond = true ) : active(cond) {
129+ if (!active)
130+ return ;
128131 __asm__ __volatile__ (
129132 R"(
130133 .arch_extension memtag
@@ -135,6 +138,8 @@ class ScopedDisableMemoryTagChecks {
135138 }
136139
137140 ~ScopedDisableMemoryTagChecks () {
141+ if (!active)
142+ return ;
138143 __asm__ __volatile__ (
139144 R"(
140145 .arch_extension memtag
@@ -269,7 +274,7 @@ inline NORETURN void enableSystemMemoryTaggingTestOnly() {
269274}
270275
271276struct ScopedDisableMemoryTagChecks {
272- ScopedDisableMemoryTagChecks () {}
277+ ScopedDisableMemoryTagChecks (UNUSED bool cond = true ) {}
273278};
274279
275280inline NORETURN uptr selectRandomTag (uptr Ptr, uptr ExcludeMask) {
You can’t perform that action at this time.
0 commit comments