[compiler-rt] [scudo] Add primary option to zero block on dealloc. (PR #142394)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 17 22:08:33 PDT 2025
ChiaHungDuan wrote:
> > I think this is better to be done in `deallocate()` path in combined.h.
>
> * Zeroing is only useful for the primary allocator, where objects are small, and when all objects of a given page are zeroed, the page can be reclaimed by the OS. The secondary allocator can affort to simply releases the memory to the operating system because it is working on large objects.
> * In combined.h there are also two code path to deallocate depending on whenever the block is quarantined or not.
>
> That why I have a some preference for the SizeClassAllocator. Can you double check and let me know if you prefer to move this code to `combined.h`?
Zeroing-on-free is also a security feature ans that's why I think it is good to have. But it seems to me this is introduced for specific platform, then we may want to consider if we can implement it on platform side. For example, the malloc/free hooks. In addition, the size of blocks in the primary allocator can be large (like several pages), it depends on the configuration. So even if you only zeroing blocks in primary allocator, it can still cause some performance issue.
We do have a way to implement this only for certain sizes but I would suggest having more discussion before we make it a formal feature in Scudo
https://github.com/llvm/llvm-project/pull/142394
More information about the llvm-commits
mailing list