Dobby will try to place a jmp trampoline and consequently overwrite the instruction.
As a result Dobby will relocate _Z27__bionic_atfork_run_preparev in the relocation stub.
However, the generated relocation stub looks like this:
Due to the call at 00007F63B634F004 and the call target being placed at 00007F63B634F00A, the caller will continue execution at 00007F63B634F00A when returning from _Z27__bionic_atfork_run_preparev leading to a crash/undefined behaviour.
I modified InstructionRelocationX86Shared.cc such that it will place a jmp after the call, meaning when returning from the call it will jump over the data:
There is a bug in the relocation of call instructions when doing inline hooks. Consider the following function prologue in x64 as an example:
Dobby will try to place a jmp trampoline and consequently overwrite the instruction. As a result Dobby will relocate
_Z27__bionic_atfork_run_preparev
in the relocation stub.However, the generated relocation stub looks like this:
Due to the call at
00007F63B634F004
and the call target being placed at00007F63B634F00A
, the caller will continue execution at00007F63B634F00A
when returning from_Z27__bionic_atfork_run_preparev
leading to a crash/undefined behaviour.I modified
InstructionRelocationX86Shared.cc
such that it will place a jmp after the call, meaning when returning from the call it will jump over the data: