You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A large chunk (size >= 4080) is not handled correctly and can be reclaimed even if a dangling pointer exists.
In the PoC code, we allocate and free chunk a, and create memory pressure while keeping a dangling pointer to a. After that, memory for chunk a is reclaimed when we allocate chunk b.
MarkUs should have detected a reference to the chunk a in the stack and delayed it's free.
a = 0x563827e37000, a[0] = 41414141
freed a
gc...
b = 0x563827e37000, b[0] = 42424242
a = 0x563827e37000, a[0] = 42424242
PoC Code generated by Hardsheap:
// The number of actions: 5// chunk 2 is reused to chunk 0 at a probability of 1.000000#include<stdio.h>#include<stdlib.h>#include<stdint.h>#include<malloc.h>void*p[256];
uintptr_tbuf[256];
intmain() {
p[0] =malloc(842373);
p[1] =malloc(842389);
free(p[1]);
free(p[0]);
p[2] =malloc(842373);
return0;
}
The text was updated successfully, but these errors were encountered:
Thanks Jungwon! The bug was in the code for Munmapped regions, which shouldn't be walked for pointers because 1) it's unnecessary and 2) it would cause a segfault. That code mistakenly also caused the mark bit not to be set on the discovery of a pointer to such a region, which is now fixed.
That now prevents these two PoC, and I believe fixes the bug in general.
The Bug
A large chunk (size >= 4080) is not handled correctly and can be reclaimed even if a dangling pointer exists.
In the PoC code, we allocate and free chunk
a
, and create memory pressure while keeping a dangling pointer toa
. After that, memory for chunka
is reclaimed when we allocate chunkb
.MarkUs should have detected a reference to the chunk
a
in the stack and delayed it's free.Proof of Concept
PoC Code:
Output:
PoC Code generated by Hardsheap:
The text was updated successfully, but these errors were encountered: