Re: [PATCH bpf-next v3 1/2] bpf: Make the pointer returned by iter next method valid
From: Alexei Starovoitov
Date: Thu Aug 29 2024 - 14:39:46 EST
On Thu, Aug 29, 2024 at 3:45 AM Juntong Deng <juntong.deng@xxxxxxxxxxx> wrote:
>
> if (prev_st)
> @@ -12860,6 +12867,16 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
> /* For mark_ptr_or_null_reg, see 93c230e3f5bd6 */
> regs[BPF_REG_0].id = ++env->id_gen;
> }
> +
> + if (is_iter_next_kfunc(&meta) && base_type(regs[BPF_REG_0].type) != PTR_TO_MEM) {
The != PTR_TO_MEM part is a bit ugly.
Why not do it in {} scope right above?
Just move it up by a few lines?
Right after regs[BPF_REG_0].type = PTR_TO_BTF_ID;