Skip to content

[scudo] Add two missing locks to enable/disable. #79670

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 4 commits into from
Jan 29, 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
2 changes: 2 additions & 0 deletions compiler-rt/lib/scudo/standalone/combined.h
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,12 @@ class Allocator {
Quarantine.disable();
Primary.disable();
Secondary.disable();
Depot.disable();
}

void enable() NO_THREAD_SAFETY_ANALYSIS {
initThreadMaybe();
Depot.enable();
Secondary.enable();
Primary.enable();
Quarantine.enable();
Expand Down
7 changes: 7 additions & 0 deletions compiler-rt/lib/scudo/standalone/stack_depot.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ class StackDepot {
u64 operator[](uptr RingPos) const {
return atomic_load_relaxed(&Ring[RingPos & RingMask]);
}

// This is done for the purpose of fork safety in multithreaded programs and
// does not fully disable StackDepot. In particular, find() still works and
// only insert() is blocked.
void disable() NO_THREAD_SAFETY_ANALYSIS { RingEndMu.lock(); }

void enable() NO_THREAD_SAFETY_ANALYSIS { RingEndMu.unlock(); }
};

} // namespace scudo
Expand Down