See Heap overflow--malloc and free from source

Source: Internet
Author: User

There are many articles about the use of Linux under the heap, which I have summed up before, but not in-depth investigation. This time from the source to analyze why it is used, how to be used. The so-called source is the heap management mechanism, in more detail is the MALLC () and the free () function in libc.so.

Directory

The meaning of the existence of the 0x0 heap the existence of the heap management function of the 0x0 heap is found

First, the heap mechanism, the white heap is just a user-state memory management mechanism. Heap management mechanism is set up to improve the efficiency of memory usage, if there is no heap can you? Of course, it is possible to allocate memory every time you need to use mmap (or similar function kernel operation) in the virtual address space, each time you need to allocate back to release. I have not studied the memory management mechanism in the kernel of Linux, but for Windows it can be summed up like this: Windows uses VAD to describe a process's virtual address space, VAD is a tree-like data structure, Each time a memory is allocated, a node that is attached to the Vad tree represents this block of user-State address space has been allocated, so if there is no heap mechanism, every time to allocate memory to operate the VAD tree. This is very inefficient, VAD is the structure of the kernel, is attached to the eprocess of the corresponding process, want to learn more about the Windows Kernel memory management can be seen in the Windows Kernel scenario analysis book. In addition, many concrete implementations of the heap are different, and can even implement their own heap management mechanism functions.

0x1 found heap management function

To find the heap management function, first find the libc.so library used. Libc.so is the standard C function library, and the C library is no use for Windows. But for Linux systems, the C function library even corresponds to the underlying call.

  

See Heap overflow--malloc and free from source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.