C++ and other languages that rely on explicit memory management using malloc()
and free()
are prone to memory corruptions and the resulting security issues. The fundamental idea behind these heap scanning algorithms is to intercept an underlying allocator and delay releasing of memory until the corresponding memory block is provably unreachable from application code.
The basic ingredients for such algorithms are:
free()
call, it is put into quarantine instead of being returned to the allocator. The object is not actually freed by the underlying allocator and cannot be used for future allocation requests until it is found that no pointers are pointing to the given memory block.Heap scanning algorithms come in different flavors that offer different performance and security characteristics.
Probabilistic conservative scan (PCScan) (pcscan.{h,cc}
) is one particular kind of heap scanning algorithm implemented on top of PartitionAlloc with the following properties:
PCScan is currently considered experimental - please do not use it in production code just yet. It can be enabled in the following configurations via --enable-features
on builds that use PartitionAlloc as the main allocator:
PartitionAllocPCScan
: All processes and all supporting partitions enable PCScan.PartitionAllocPCScanBrowserOnly
: Enables PCScan in the browser process for the default malloc partition.