V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
dangyuluo
V2EX  ›  C

Glibc 的 Malloc 有时候不会把 free 的内存还给 OS,有趣的发现

  •  
  •   dangyuluo · 2023-02-08 05:39:23 +08:00 · 1603 次点击
    这是一个创建于 447 天前的主题,其中的信息可能已经有所发展或是发生改变。

    假设我们对 Glibc malloc 和 free 的实现一无所知,malloc 了一大堆内存后在挨个 free 掉,会发现 free 的顺序实际上决定是否将内存返回给 OS ,看最后一个system bytes

    下一步是读 malloc 的源码,估计是用一个 linked list 来管理 heap 内存的

    3 条回复    2023-02-08 09:58:57 +08:00
    tyzandhr
        1
    tyzandhr  
       2023-02-08 06:09:45 +08:00 via Android
    不是新发现了。建议用 tcmalloc
    nopnewbie
        2
    nopnewbie  
       2023-02-08 09:32:17 +08:00   ❤️ 2
    嗯,现在你已经学会 ptmalloc2 的源码了,那么你就可以就来做几道 glibc heap overflow 的 pwn 吧。
    bfdh
        3
    bfdh  
       2023-02-08 09:58:57 +08:00
    内存空洞
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5240 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 09:07 · PVG 17:07 · LAX 02:07 · JFK 05:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.