Re: [PATCH RFC bpf-next 15/31] bpf: Add get_func_arg[_cnt] support for kprobe multi functions

From: Jiri Olsa

Date: Thu Dec 03 2026 - 09:42:22 EST


On Thu, Dec 03, 2026 at 01:53:11AM +0000, Alexei Starovoitov wrote:
> On Wed, Dec 02, 2026 at 04:30 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> > + cnt = kprobe_multi_entry_args_cnt(run_ctx);
> > + if (cnt < 0)
> > + return cnt;
> > + if (n >= cnt)
> > + return -EINVAL;
> > + *value = ftrace_regs_get_argument(run_ctx->fregs, n);
>
> cnt is the number of args, but n selects a register.
> They differ when a struct takes two registers. sockptr_t has 16 bytes:
>
> sk_setsockopt(sk, level, optname, sockptr_t optval, optlen)
> rdi rsi rdx rcx:r8 r9
>
> n fentry entry, this patch inlined, patch 16
> - ----------- ----------------- -----------------
> 3 optval, rcx optval, rcx -EOPNOTSUPP
> 4 optval, r8 optval, r8 optlen
> 5 optlen -EINVAL -EINVAL
>
> optlen can't be read at the entry.
> The same prog gets a different arg for n == 4 at an inlined instance.
> Should n mean the same as in fentry?
>

right, it should.. helpers go away with the addrs[] change, but the
arg specs have the same problem, user space would need its own copy
of bpf_jit_place_args with the arch tables to get the slots right

hum, I need to check more, but I wonder if we should keep the
bpf_get_func_arg helpers in the kernel after all.. it's a lot of
complicated code for user space tracer, while kernel can reuse
what fentry already has

thanks,
jirka