OpenDevicePartnership / OpenDevicePartnership/patina

[Feature]: Unmap Unused Allocator Pages

Open
#603 0 comments 0 reactions 1 assignee View on GitHub

@os-d is already working on this.

Since Jul 18, 2025.

state:needs-triage type:feature-request urgency:low
Dominant language
Rust
Stars
544
Forks
54
Avg merge
1d 8h
Merged PRs (30d)
30

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.