OpenDevicePartnership / OpenDevicePartnership/patina
[Feature]: Unmap Unused Allocator Pages
Open
@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
- Remove the 4K block list.
- 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.
- 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.
- 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.
- 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.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.