Re: [PATCH v2 15/39] x86/ibt,kprobes: Fix more +0 assumptions

From: Peter Zijlstra
Date: Wed Mar 02 2022 - 14:40:14 EST


On Wed, Mar 02, 2022 at 08:32:45PM +0100, Peter Zijlstra wrote:
> I wonder if you also want to tighten up on_func_entry? Wouldn't the
> above suggest something like:
>
> kprobe_opcode_t *arch_adjust_kprobe_addr(unsigned long addr, unsigned long offset,
> bool *on_func_entry)
> {
> #ifdef PPC64_ELF_ABI_V2
> unsigned long entry = ppc_function_entry((void *)addr) - addr;
> *on_func_entry = !offset || offset == entry;
> if (*on_func_entry)
> offset = entry;
> #else
> *on_func_entry = !offset;
> #endif
> return (void *)(addr + offset);
> }

One question though; the above seems to work for +0 or +8 (IIRC your
instructions are 4 bytes each and the GEP is 2 instructions).

But what do we want to happen for +4 ?