Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freelist allocation batching can cause use after free #5

Open
Dante-Broggi opened this issue Jul 10, 2023 · 0 comments
Open

Freelist allocation batching can cause use after free #5

Dante-Broggi opened this issue Jul 10, 2023 · 0 comments

Comments

@Dante-Broggi
Copy link

Just from observation of the freelist (and shared freelist) code (without compiling to test), I believe the following series of operations can result in a use after free:

auto alloc = Freelist!(Mallocator, 64);
auto a1 = alloc.allocate(64);
auto a2 = alloc.allocate(64);
assert(alloc.reallocate(a1, 8*64)); // the default batch size, assume it reallocs in place.
// a1 now overlaps a2 because the reallocation was in place, 
// as from malloc's perspective it was a no-op reallocate. 
alloc.deallocate(a1);
use(a2); // a2 was freed by the previous line, due to overlap.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant