Re: [PATCH bpf-next v2 2/5] bpf, x86: allow function arguments up to 14 for TRACING

From: Menglong Dong
Date: Fri Jun 02 2023 - 03:41:39 EST


On Fri, Jun 2, 2023 at 3:01 PM <menglong8.dong@xxxxxxxxx> wrote:
>
> From: Menglong Dong <imagedong@xxxxxxxxxxx>
> @@ -2262,6 +2327,7 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i
>
> if (flags & BPF_TRAMP_F_CALL_ORIG) {
> restore_regs(m, &prog, nr_regs, regs_off);
> + prepare_origin_stack(m, &prog, nr_regs, arg_stack_off);
>
> if (flags & BPF_TRAMP_F_ORIG_STACK) {
> emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, 8);
> @@ -2321,14 +2387,14 @@ int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *i
> if (save_ret)
> emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, -8);
>
> - EMIT1(0x5B); /* pop rbx */
> + emit_ldx(&prog, BPF_DW, BPF_REG_6, BPF_REG_FP, -rbx_off);
> EMIT1(0xC9); /* leave */
> if (flags & BPF_TRAMP_F_SKIP_FRAME)
> /* skip our return address and return to parent */
> EMIT4(0x48, 0x83, 0xC4, 8); /* add rsp, 8 */
> emit_return(&prog, prog);
> /* Make sure the trampoline generation logic doesn't overflow */
> - if (WARN_ON_ONCE(prog > (u8 *)image_end - BPF_INSN_SAFETY)) {
> + if (prog > (u8 *)image_end - BPF_INSN_SAFETY) {

Oops, this line is a mistake, and I should keep it still.

> ret = -EFAULT;
> goto cleanup;
> }
> --
> 2.40.1
>