1 the first malloc stop 1, back from malloc in push(7) the chunks of 0x20 the program's list · malloc's free list the program's 405010 0 dummy tcache top 0x20fe0 405020 rax its bytes the heap, 405000 to 40506f 4050 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 10 00 00 00 00 00 00 00 00 0 00 00 00 00 00 00 00 00 NULL 4050 20 00 00 00 00 00 00 00 00 e1 0f 02 00 00 00 00 00 0x20fe0 a m P top 4050 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4050 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4050 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4050 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 malloc(16) cut a chunk of 0x20 off the top: its size word, 0x21, then the 16 bytes rax points at. The top is 0x20 smaller. 2 three chunks stop 6, after push(9) the chunks of 0x20 the program's list · malloc's free list the program's 405050 405030 405010 9 12 7 dummy tcache top 0x20fa0 405060 head head its bytes the heap, 405000 to 40506f 4050 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 10 07 00 00 00 00 00 00 00 7 00 00 00 00 00 00 00 00 NULL 4050 20 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 30 0c 00 00 00 00 00 00 00 12 10 50 40 00 00 00 00 00 405010 4050 40 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 50 09 00 00 00 00 00 00 00 9 30 50 40 00 00 00 00 00 405030 4050 60 00 00 00 00 00 00 00 00 a1 0f 02 00 00 00 00 00 0x20fa0 a m P top Three pushes, three chunks in a row, each with P: the chunk before it is in use. The list's next pointers are arcs in the bytes. 3 a free stop 7, back from free in the first pop the chunks of 0x20 the program's list · malloc's free list the program's 405030 405010 12 7 tcache 0x20 1 405050 key top 0x20ca0 405360 head head rdi its bytes the heap, 405000 to 40506f 4050 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 10 07 00 00 00 00 00 00 00 7 00 00 00 00 00 00 00 00 NULL 4050 20 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 30 0c 00 00 00 00 00 00 00 12 10 50 40 00 00 00 00 00 405010 4050 40 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 50 05 04 00 00 00 00 00 00 NULL ^ 405 53 89 03 0a cf c5 9f 6b key 4050 60 00 00 00 00 00 00 00 00 01 03 00 00 00 00 00 00 0x300 a m P tcache tcache → 405070 tcache_perthread_struct · 0x2f0 bytes 405 070 0f 00 15 slots left · 1 in the bin 10 00 10 00 10 00 10 00 10 00 10 00 10 00 8 rows 405 100 10 00 10 00 10 00 10 00 50 50 40 00 00 00 00 00 405050 405 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 rows free gave 9's chunk to the tcache, malloc's bin for 0x20. Its first word is the link now: 405, which is NULL, safe-linked. 4 a second free stop 8, back from free in the second pop the chunks of 0x20 the program's list · malloc's free list the program's 405010 7 tcache 0x20 2 405030 key 405050 key top 0x20ca0 405360 head head rdi its bytes the heap, 405000 to 40506f 4050 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 10 07 00 00 00 00 00 00 00 7 00 00 00 00 00 00 00 00 NULL 4050 20 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 30 55 54 40 00 00 00 00 00 405050 ^ 405 53 89 03 0a cf c5 9f 6b key 4050 40 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 50 05 04 00 00 00 00 00 00 NULL ^ 405 53 89 03 0a cf c5 9f 6b key 4050 60 00 00 00 00 00 00 00 00 01 03 00 00 00 00 00 00 0x300 a m P tcache tcache → 405070 tcache_perthread_struct · 0x2f0 bytes 405 070 0e 00 14 slots left · 2 in the bin 10 00 10 00 10 00 10 00 10 00 10 00 10 00 8 rows 405 100 10 00 10 00 10 00 10 00 30 50 40 00 00 00 00 00 405030 405 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 rows The second chains to the first: 405455 is 405050 xor 405, the chunk's own address shifted 12. The arc is the pointer it hides. 5 malloc takes it back stop 9, back from malloc in push(25) the chunks of 0x20 the program's list · malloc's free list the program's 405030 405010 405455 7 tcache 0x20 1 405050 key top 0x20ca0 405360 rax head head its bytes the heap, 405000 to 40506f 4050 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 10 07 00 00 00 00 00 00 00 7 00 00 00 00 00 00 00 00 NULL 4050 20 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 30 55 54 40 00 00 00 00 00 the old link 00 00 00 00 00 00 00 00 NULL 4050 40 00 00 00 00 00 00 00 00 21 00 00 00 00 00 00 00 0x20 a m P 4050 50 05 04 00 00 00 00 00 00 NULL ^ 405 53 89 03 0a cf c5 9f 6b key 4050 60 00 00 00 00 00 00 00 00 01 03 00 00 00 00 00 00 0x300 a m P tcache tcache → 405070 tcache_perthread_struct · 0x2f0 bytes 405 070 0f 00 15 slots left · 1 in the bin 10 00 10 00 10 00 10 00 10 00 10 00 10 00 8 rows 405 100 10 00 10 00 10 00 10 00 50 50 40 00 00 00 00 00 405050 405 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 36 rows malloc(16) took the bin's head, 405030: the tcache points at 405050 again, the key is wiped, and the old link stays until push writes.