/* There is one of these for each thread, which contains the per-thread cache (hence "tcache_perthread_struct"). Keeping overall size low is mildly important. Note that COUNTS and ENTRIES are redundant (we could have just counted the linked list each time), this is for performance reasons. */ typedefstructtcache_perthread_struct { char counts[TCACHE_MAX_BINS]; tcache_entry *entries[TCACHE_MAX_BINS]; } tcache_perthread_struct;
A = malloc(0x8) B = malloc(0x8) free(A) free(B) #由于头插头取,tcache的结构如下: #0x20[2]: B -> A #通过uaf等利用手段。将B的前8字节内容改为free_hook/malloc_hook即: #0x20[2]: B -> free_hook/malloc_hook C = malloc(0x8) # B D = malloc(0x8) # free_hook/malloc_hook #D就申请到hook的位置上了,可以任意修改hook内容。 #如果改为malloc_hook,可以写one_gadget #如果改为free_hook,可以写one_gadget,或者写system并释放一个内容为'/bin/sh'的块