Linux内核将堆栈指针的内容作为限制(在合理的边界内)。访问堆栈
在下面
堆栈指针减去65536和32个无符号长整型的大小会导致分段冲突。因此,如果您通过堆栈访问内存,必须确保堆栈指针在某种程度上随Linux内核的访问而减小,从而扩大段。查看以下代码段
/arch/x86/mm/fault.c
:
if (sw_error_code & X86_PF_USER) {
/*
* Accessing the stack below %sp is always a bug.
* The large cushion allows instructions like enter
* and pusha to work. ("enter $65535, $31" pushes
* 32 pointers and then decrements %sp by 65535.)
*/
if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
bad_area(regs, sw_error_code, address);
return;
}
}
堆栈指针寄存器的值在这里是键!