[PATCH bpf v3] riscv, bpf: Emit fixed-length instructions for BPF_PSEUDO_FUNC

Björn Töpel bjorn at kernel.org
Tue Dec 6 02:57:55 PST 2022


Pu Lehui <pulehui at huaweicloud.com> writes:

> From: Pu Lehui <pulehui at huawei.com>
>
> For BPF_PSEUDO_FUNC instruction, verifier will refill imm with
> correct addresses of bpf_calls and then run last pass of JIT.
> Since the emit_imm of RV64 is variable-length, which will emit
> appropriate length instructions accorroding to the imm, it may
> broke ctx->offset, and lead to unpredictable problem, such as
> inaccurate jump. So let's fix it with fixed-length instructions.
>
> Fixes: 69c087ba6225 ("bpf: Add bpf_for_each_map_elem() helper")
> Signed-off-by: Pu Lehui <pulehui at huawei.com>
> Suggested-by: Björn Töpel <bjorn at rivosinc.com>

Thank you!

Acked-by: Björn Töpel <bjorn at kernel.org>
Reviewed-by: Björn Töpel <bjorn at kernel.org>



More information about the linux-riscv mailing list