From: Alexei Starovoitov The address of a variable in an arena is a scalar for the verifier. check_ld_imm() used to set map_ptr first and to call __mark_reg_unknown() then, which cleared it. Since commit 022ac0750883 ("bpf: use reg->var_off instead of reg->off for pointers") the assignment stands behind the call, and the scalar keeps a pointer to the map. map_ptr means nothing in a scalar. But reg_value_equal() compares the whole union, so two equal scalars can look different. ADD, SUB, MUL and the shifts keep the pointer, NEG and an AND that gives a constant clear it. Remove the assignment. Now a SCALAR_VALUE has no ids and an empty union: verifier.c sets the type in 14 places, each time on a register that __mark_reg_known() or bpf_mark_reg_unknown() clears, and a load from ctx calls mark_reg_unknown(). Nothing else writes an id or a member of the union of a scalar. The next patch relies on it. Signed-off-by: Alexei Starovoitov --- kernel/bpf/verifier.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 56924ce392e0..ed1ec6c2a21a 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -19927,7 +19927,6 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn) insn->src_reg == BPF_PSEUDO_MAP_IDX_VALUE) { if (map->map_type == BPF_MAP_TYPE_ARENA) { bpf_mark_reg_unknown(dst_reg); - dst_reg->map_ptr = map; bpf_diag_mod_end(env); return 0; } -- 2.55.0