Re: [PATCH 2/2] x86/bpf: Fix IP for relocating call depth accounting

From: Ingo Molnar
Date: Thu Mar 21 2024 - 05:05:20 EST



* Joan Bruguera Micó <joanbrugueram@xxxxxxxxx> wrote:

> The recently introduced support for %rip-relative relocations in the
> call thunk template assumes that the code is being patched in-place,
> so the destination of the relocation matches the address of the code.
> This is not true for the call depth accounting emitted by the BPF JIT,
> so the calculated address is wrong and usually causes a page fault.
>
> Pass the destination IP when the BPF JIT emits call depth accounting.
>
> Fixes: 17bce3b2ae2d ("x86/callthunks: Handle %rip-relative relocations in call thunk template")
> Signed-off-by: Joan Bruguera Micó <joanbrugueram@xxxxxxxxx>
> ---
> arch/x86/include/asm/alternative.h | 4 ++--
> arch/x86/kernel/callthunks.c | 4 ++--

For the generic x86 changes - I guess you want to push this upstream via
the networking tree:

Acked-by: Ingo Molnar <mingo@xxxxxxxxxx>

Thanks,

Ingo