snmalloc icon indicating copy to clipboard operation
snmalloc copied to clipboard

override add malloc_conceal api proposal

Open devnexen opened this issue 4 years ago • 3 comments

devnexen avatar Nov 30 '21 22:11 devnexen

Hi, I've thought about adding this API. I think the correct way of doing it is:

  • Extend the PALs to support no-core memory as a class-template parameter.
  • Create a separate allocator instance that allocates slabs using the no-core Pal.
  • Have these APIs use the second allocator instance.

They can share the pagemap with other allocators and they should be returned to the pools.

Libsodium's secure allocator also supports rounding up allocations to page size, allocating them at the end of the page and putting guard pages on either side. Once the PAL can provide no-core pages, this should also be possible through the large-object paths in the allocator. The allocator rounds up to the page size so that you can mprotect the memory read-only or no-access later.

davidchisnall avatar Dec 01 '21 09:12 davidchisnall

This is a really interesting idea. I am not sure what the granularity of NODUMP should be.

       The Linux implementation requires that the address addr be page-
       aligned, and allows length to be zero.

If this is at a Page granularity, then we probably need to allocate whole slabs with NODUMP set. This is doable, but would involve adding a completely different set of sizeclasses for concealed allocations.

Adding NODUMP to the PAL is something I have been meaning to do, to address #371.

mjp41 avatar Dec 01 '21 09:12 mjp41

This is a really interesting idea. I am not sure what the granularity of NODUMP should be.

       The Linux implementation requires that the address addr be page-
       aligned, and allows length to be zero.

If this is at a Page granularity, then we probably need to allocate whole slabs with NODUMP set. This is doable, but would involve adding a completely different set of sizeclasses for concealed allocations.

you re perfectly right it has to, I was just assessing if the overall idea would hit home before going deeper.

devnexen avatar Dec 01 '21 10:12 devnexen