
glibc
文章平均质量分 56
huzai9527
这个作者很懒,什么都没留下…
展开
-
【tcache stash unlink +】图解
tcache stashing unlink +tcache 的入链操作smallbin 入链操作tcache stash源码#if USE_TCACHE /* While we're here, if we see other chunks of the same size, stash them in the tcache. */ size_t tc_idx = csize2tidx (nb); if (tcache原创 2021-11-09 17:54:00 · 415 阅读 · 0 评论 -
【large bin 】源码解析
large bin attacklarge bin的结构网找了好久,没有一个形象的理解确实读源码不方便,找了好久,mkx7师傅的这篇文章总结的及其好!largebin 入bin操作当确定victim的大小在largebin范围后,如何将victim插入larbin的过程如下首先判断largebin 是否为空如果空的直接设置victim为victim size大小的chunk 头节点,并将fd_nextsize和bk_nextsize设置为victm如果largebin 不原创 2021-11-09 14:30:16 · 713 阅读 · 0 评论 -
glibc中free函数详解
__libc_free详解(tcache 略)1. 检查是否存在 hook函数,如果有就执行void__libc_free (void *mem){ mstate ar_ptr; mchunkptr p; /* chunk corresponding to mem *//* 1. 关于__free_hook,释放时会检查其会否为NULL,否的话就执行相应的函数 2. __free_hook指向的函数,其调用的参数,为chunk中的内容原创 2021-05-27 09:51:38 · 1008 阅读 · 0 评论 -
glibc 堆的管理
堆介绍结构示意图N位:define NON_MAIN_ARENA 用于表示是否属于主线程,0表示主线程的堆块结构,1表示子线程的堆块结构M位:define IS_MAPPED 0X2 用于表示是否由mmap分配,0表示由堆块中的top chunk分裂产生,1表示由mmap分配P位:define PREV_ISUSE 0x1 用于表示上一堆块是否处于空闲状态,0表示处于空闲状态,1表示处于使用状态。主要用于来判断free是否能够上一堆块进行合并堆空闲块管理结构bin原创 2021-01-21 09:36:30 · 233 阅读 · 0 评论 -
glibc TCache机制
TCache机制相关的宏#if USE_TCACHE/* We want 64 entries. This is an arbitrary limit, which tunables can reduce. */# define TCACHE_MAX_BINS 64# define MAX_TCACHE_SIZE tidx2usize (TCACHE_MAX_BINS-1)/* Only used to pre-fill the tunables. */# define tidx原创 2021-01-20 15:06:12 · 1317 阅读 · 0 评论 -
glibc __libc_free() 源码分析
__libc_free()检查是否存在 hook函数,如果有就执行void__libc_free (void *mem){ mstate ar_ptr; mchunkptr p; /* chunk corresponding to mem */ void (*hook) (void *, const void *) = atomic_forced_read (__free_hook); if (__builtin_exp原创 2021-01-20 11:45:30 · 1257 阅读 · 0 评论 -
__libc_malloc()源码阅读
malloc 源码chunk 与 mem 指针头部的转换(mem 指向用户申请的内存空间)/* conversion from malloc headers to user pointers, and back */#define chunk2mem(p) ((void *) ((char *) (p) + 2 * SIZE_SZ))#define mem2chunk(mem) ((mchunkptr)((char *) (mem) -2 * SIZE_SZ))检查分配给用户的内存是否对原创 2021-01-19 16:16:31 · 1750 阅读 · 0 评论 -
glibc堆概述
glibc堆概述1.内存管理与堆程序内存布局brk() 和 sbrk()堆的属性是可读可写的,大小通过sbrk和brk进行控制。函数描述NAME brk, sbrk - change data segment sizeDESCRIPTION brk() and sbrk() change the location of the program break, which de‐ fines the end of the proce原创 2021-01-19 16:12:48 · 252 阅读 · 0 评论