[scudo][standalone] Do not fill 32b regions at once
authorKostya Kortchinsky <kostyak@google.com>
Tue, 3 Mar 2020 19:16:31 +0000 (11:16 -0800)
committerKostya Kortchinsky <kostyak@google.com>
Wed, 4 Mar 2020 22:22:24 +0000 (14:22 -0800)
commita0e86420ae72e4dc38c3a341943d4f14139e1e4b
treefb2d1432bb3e0379286842eceab32f6488ff1e38
parent15bf916b548ed70a38545c1837de08a4da70425c
[scudo][standalone] Do not fill 32b regions at once

Summary:
For the 32b primary, whenever we created a region, we would fill it
all at once (eg: create all the transfer batches for all the blocks
in that region). This wasn't ideal as all the potential blocks in
a newly created region might not be consummed right away, and it was
using extra memory (and release cycles) to keep all those free
blocks.

So now we keep track of the current region for a given class, and
how filled it is, carving out at most `MaxNumBatches` worth of
blocks at a time.

Additionally, lower `MaxNumBatches` on Android from 8 to 4. This
lowers the randomness of blocks, which isn't ideal for security, but
keeps things more clumped up for PSS/RSS accounting purposes.

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D75551
compiler-rt/lib/scudo/standalone/primary32.h
compiler-rt/lib/scudo/standalone/primary64.h