From 2a97030c9743d4680d698414c28e8d8739614215 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 23:25:40 -0300 Subject: design: down is deeper; a call followed down; operands without size words; the heap as a scene From the user. Direction and nearness are rules: the idea, the source, its instructions, the callee and the kernel go down the frame, a call goes down and a return comes up, and every tie runs one of those ways. The disassembly can descend: a window a call depth, the caller keeping three rows with its call waiting, a PLT stub its jump, the kernel at the bottom on vellum, with verbs descend, cross and ascend. The kernel leaves the band, which keeps the calls so far as strace writes them; the backtrace has its newest frame at the bottom. Size words are dropped from operands and a width is shown as byte cells where nothing else says it; a compare shows its values and flags, a jump the flags it reads, an indirect call its target and the slot it was read from. libc's heap is a scene of blocks that exist (a dump by fields with a size and a protected pointer read, arcs as the free list, a loupe into the tcache, the list drawn over malloc's own), storyboarded on glibc 2.44. Mocks 16 to 18. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- design/mock/18-heap.svg | 1460 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1460 insertions(+) create mode 100644 design/mock/18-heap.svg (limited to 'design/mock/18-heap.svg') diff --git a/design/mock/18-heap.svg b/design/mock/18-heap.svg new file mode 100644 index 0000000..cf60bb3 --- /dev/null +++ b/design/mock/18-heap.svg @@ -0,0 +1,1460 @@ + + + + +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. + + -- cgit v1.3