Skip to content

Commit 9d98aa0

Browse files
ubizjakAlexei Starovoitov
authored andcommitted
x86/bpf: Fix IP after emitting call depth accounting
Adjust the IP passed to `emit_patch` so it calculates the correct offset for the CALL instruction if `x86_call_depth_emit_accounting` emits code. Otherwise we will skip some instructions and most likely crash. Fixes: b2e9dfe ("x86/bpf: Emit call depth accounting if required") Link: https://lore.kernel.org/lkml/[email protected]/ Co-developed-by: Joan Bruguera Micó <[email protected]> Signed-off-by: Joan Bruguera Micó <[email protected]> Signed-off-by: Uros Bizjak <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 6dae957 commit 9d98aa0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/net/bpf_jit_comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static int emit_call(u8 **pprog, void *func, void *ip)
480480
static int emit_rsb_call(u8 **pprog, void *func, void *ip)
481481
{
482482
OPTIMIZER_HIDE_VAR(func);
483-
x86_call_depth_emit_accounting(pprog, func);
483+
ip += x86_call_depth_emit_accounting(pprog, func);
484484
return emit_patch(pprog, func, ip, 0xE8);
485485
}
486486

0 commit comments

Comments
 (0)