The red zone is stack space that's safe from asynchronous modification even though it's not reserved the normal way. Some ABIs (notably the x86-64 SysV ABI) provide one.
The red zone is a fixed-length area of stack space that's safe from asynchronous modification (by signals or interrupts) even though it's outside the reserved part of the stack. (e.g. the first 128 bytes below rsp
in the SysV ABI for x86-64, where the stack grows down. See the x86 tag wiki.)
It can be used as a temporary scratch area for the function, in order to avoid having to spend 2 instructions to decrement and increment the stack pointer. The red zone is not preserved across function calls, so it's best used for leaf functions, or in a function tail.
Compiler options can disable use of the red zone for compiler-generated code. For example, Linux kernel code is compiled with -mno-red-zone
because it's very difficult if not impossible for x86 interrupt handlers to respect the standard 128B red-zone, unlike signal handlers respecting the user-space stack's red-zone.
The location and implementation of the red zone differs by platform (operating system) abi.
Resources