Commit e56ee14a authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

gwp-asan: Fix potential race in GuardedPageAllocator.

|total_allocations_| is used after the mutex guarding it is released.
This CL reads its value before releasing the mutex, removing the race
condition.

Bug: 881875
Change-Id: Iba1539eb75012bb69bf2bd6631345fa9518a62cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2098017
Commit-Queue: Victor Costan <pwnall@chromium.org>
Auto-Submit: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749175}
parent 49bb7ead
......@@ -347,8 +347,9 @@ bool GuardedPageAllocator::ReserveSlotAndMetadata(
if (!oom_hit_) {
if (++consecutive_failed_allocations_ == kOutOfMemoryCount) {
oom_hit_ = true;
size_t allocations = total_allocations_ - kOutOfMemoryCount;
base::AutoUnlock unlock(lock_);
std::move(oom_callback_).Run(total_allocations_ - kOutOfMemoryCount);
std::move(oom_callback_).Run(allocations);
}
}
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment