See Thomas Pornin (+1) and other answers (+1), they are good. I want to add an additional answer that could be referenced, but not specifically specified, but this is a spill of registries.
Although the "where" of the original question (at least as indicated) is based on the false assumption that% eax is on the stack and being a register, it is not part of the x86 stack (although you can emulate any set of hardware registers on the stack, and some architectures do this, but it doesn’t matter), by the way, registers often spill / populate from the stack. Thus, it is possible to split the register value by overflowing the stack if the register was spilled onto the stack. This will require that you know the distribution mechanism of a particular compiler, and for this function call you would need to know that% eax was spilled, where it was spilled, and stomp this stack location, and when it will be next filled from its copy of the memory, he gets a new meaning. As unlikely as it seems, these attacks usually inspire reading the source code and knowing something about the compiler in question, so this is actually not so bad.
See this for more on register spills.
gcc register scatter on x86-64
https://software.intel.com/en-us/articles/dont-spill-that-register-ensuring-optimal-performance-from-intrinsics
source share