Skip to content

[scudo] Fix isOwned on MTE devices. #111060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2024
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