Skip to content

[Feature]: Unmap Unused Allocator Pages #603

Description

@os-d

Feature Overview

Catch use-after-free bugs in Patina by unmapping unused pool allocator pages.

Solution Overview

  1. Remove the 4K block list.
  2. When allocating a sub 4K block - if no free available, go to the next free block and split it in half to put it in the lower sized block list (i.e. if no 8-byte blocks, grab the next 16-byte block, and allocate the first half, and mark the second half free and put it in the 8-byte list). Repeat until all block lists have been checked.
  3. If no block lists can satisfy allocation, get a new allocation from fallback allocator and split it into two free entries in the 2048 bucket, and rerun 2.
  4. if allocation is > 4K, simply go straight to fallback allocator and allocate whatever number of pages. For simplicity, fallback allocator would always allocate in page-size granularity - for > 4K allocations, that means that the remaining space in the page is just unused.
  5. when free-ing a block, put free signature and length into the BlockListNode, then check from start of containing page to see if you can construct a whole free page.
  6. if you can construct a whole page, remove all constituent blocks from the various free lists (simplified by adding a prev pointer so you can just remove them without finding them in the list) and free the corresponding page back to the fallback_allocator.

Alternatives Considered

No response

Urgency

Medium

Are you going to implement the feature request?

I will implement the feature

Do you need maintainer feedback?

No maintainer feedback needed

Anything else?

No response

Activity

  1. self-assigned this
    on Jul 18, 2025
  2. moved this to Committed in Patinaon Jul 31, 2025
  3. added this to the First Major Release milestone on Jul 31, 2025
  4. moved this from Committed to In Progress in Patinaon Oct 14, 2026
  5. removed this from the Backlog milestone on Oct 14, 2026
  6. os-d commented on Oct 14, 2026

    @os-d
    ContributorAuthor

    Part 1 of this was completed in #1837 , the second and final part is ongoing now.

  7. moved this from In Progress to Done in Patinaon Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions