Skip to content

Commit

Permalink
One possible fix to Buddy MIN == MAX case
Browse files Browse the repository at this point in the history
This is one possible way to fix the 0-length arrays discussed (and made into
assertion failures) in the previous commit.  This works because the Buddy's
`MIN_SIZE_BITS` is instantiated at `MIN_CHUNK_BITS`, and so the change here then
ensures that its `MAX_SIZE_BITS` is strictly greater than `MIN_CHUNK_BITS`.

A different, and possibly better, solution would be to drop the LargeBuddyRange
from CentralMetaRange when `max_page_chunk_size_bits` is computed to be equal to
`MIN_CHUNK_BITS`.
  • Loading branch information
nwf-msr committed Sep 4, 2024
1 parent b7c38ec commit 1baa4e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/snmalloc/backend/meta_protected_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace snmalloc
bits::next_pow2_bits_const(PAL::page_size);

static constexpr size_t max_page_chunk_size_bits =
bits::max(page_size_bits, MIN_CHUNK_BITS);
bits::max(page_size_bits, MIN_CHUNK_BITS + 1);

// Central source of object-range, does not pass back to GlobalR as
// that would allow flows from Objects to Meta-data, and thus UAF
Expand Down

0 comments on commit 1baa4e3

Please sign in to comment.