当一个较大的 chunk 被分割成两半后,如果剩下的部分大于 MINSIZE,就会被放到 unsorted bin 中。
/* The smallest size we can malloc is an aligned minimal chunk */
#define MINSIZE
(unsigned long) (((MIN_CHUNK_SIZE + MALLOC_ALIGN_MASK) &
~MALLOC_ALIGN_MASK))
释放一个不属于 fast bin 的 chunk,并且该 chunk 不和 top chunk 紧邻时,该 chunk 会被首先放到 unsorted bin 中。
当进行 malloc_consolidate 时,如果不是和 top chunk 近邻,可能会把合并后的 chunk 放到 unsorted bin 中
/* remove from unsorted list */
if (__glibc_unlikely (bck->fd != victim))
malloc_printerr ("malloc(): corrupted unsorted chunks 3");
unsorted_chunks (av)->bk = bck;
bck->fd = unsorted_chunks (av);
将一个unsorted bin取出时, bck->fd变为取出的unsorted bin的位置
如果可以控制bk,就能将unsorted_chunks (av)
写到任意地址
控制bk,bk = fuck_addr-0x10 (64bit),malloc,main+arena+xx就写到fuck_addr
本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议(CC BY-NC-ND 4.0)进行许可。
This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0).