Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler-rt/lib/scudo/standalone/combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,9 @@ class Allocator {
// A corrupted chunk will not be reported as owned, which is WAI.
bool isOwned(const void *Ptr) {
initThreadMaybe();
// If the allocation is not owned, the tags could be wrong.
ScopedDisableMemoryTagChecks x(
useMemoryTagging<AllocatorConfig>(Primary.Options.load()));
#ifdef GWP_ASAN_HOOKS
if (GuardedAlloc.pointerIsMine(Ptr))
return true;
Expand Down
9 changes: 7 additions & 2 deletions compiler-rt/lib/scudo/standalone/memtag.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,12 @@ inline NORETURN void enableSystemMemoryTaggingTestOnly() {

class ScopedDisableMemoryTagChecks {
uptr PrevTCO;
bool active;

public:
ScopedDisableMemoryTagChecks() {
ScopedDisableMemoryTagChecks(bool cond = true) : active(cond) {
if (!active)
return;
__asm__ __volatile__(
R"(
.arch_extension memtag
Expand All @@ -135,6 +138,8 @@ class ScopedDisableMemoryTagChecks {
}

~ScopedDisableMemoryTagChecks() {
if (!active)
return;
__asm__ __volatile__(
R"(
.arch_extension memtag
Expand Down Expand Up @@ -269,7 +274,7 @@ inline NORETURN void enableSystemMemoryTaggingTestOnly() {
}

struct ScopedDisableMemoryTagChecks {
ScopedDisableMemoryTagChecks() {}
ScopedDisableMemoryTagChecks(UNUSED bool cond = true) {}
};

inline NORETURN uptr selectRandomTag(uptr Ptr, uptr ExcludeMask) {
Expand Down
Loading