这是我的代码
#include <stdio.h>
char func_with_ret()
{
return 1;
}
void func_1()
{
char buf[16];
func_with_ret();
}
void func_2()
{
char buf[16];
getchar();
}
int main()
{
func_1();
func_2();
}
Run Code Online (Sandbox Code Playgroud)
以下是gdb对func_1和func_2的反汇编代码.
Dump of assembler code for function func_1:
0x08048427 <+0>: push ebp
0x08048428 <+1>: mov ebp,esp
0x0804842a <+3>: sub esp,0x10
0x0804842d <+6>: call 0x804841d <func_with_ret>
0x08048432 <+11>: leave
0x08048433 <+12>: ret
Dump of assembler code for function func_2:
0x08048434 <+0>: push ebp
0x08048435 <+1>: mov ebp,esp …Run Code Online (Sandbox Code Playgroud) 我在 linux 上玩了很长时间的二进制开发,最近我正在写一些基于ptmalloc 的堆开发笔记,所以我回去查看我过去解决的安全挑战中的一些有效负载,令人惊讶的是他们没有不再工作了。
比如基本的double free corruption(不是fastbin)
char *chunk1 = malloc(0xc0);
free(chunk1);
free(chunk1);
Run Code Online (Sandbox Code Playgroud)
我希望看到类似的东西
*** Error in `main': double free or corruption (top): 0x0000000000c85010 ***
Run Code Online (Sandbox Code Playgroud)
但是没有,什么也没有发生,程序正常退出。
为此,我去检查了与我的机器相对应的 glibc 源代码Debian GLIBC 2.27-2,发现malloc.c.
void *
__libc_malloc (size_t bytes)
{
...
#if USE_TCACHE
/* int_free also calls request2size, be careful to not pad twice. */
size_t tbytes;
checked_request2size (bytes, tbytes);
size_t tc_idx = csize2tidx (tbytes);
MAYBE_INIT_TCACHE ();
DIAG_PUSH_NEEDS_COMMENT;
if (tc_idx < mp_.tcache_bins
/*&& tc_idx < TCACHE_MAX_BINS*/ /* …Run Code Online (Sandbox Code Playgroud)