Skip to content

Commit a28ace7

Browse files
kkdwvdAlexei Starovoitov
authored andcommitted
bpf: Drop reg_type_may_be_refcounted_or_null
It is not scalable to maintain a list of types that can have non-zero ref_obj_id. It is never set for scalars anyway, so just remove the conditional on register types and print it whenever it is non-zero. Acked-by: Dave Marchevsky <davemarchevsky@fb.com> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Acked-by: David Vernet <void@manifault.com> Link: https://lore.kernel.org/r/20221103191013.1236066-6-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent f5e477a commit a28ace7

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

kernel/bpf/verifier.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -457,13 +457,6 @@ static bool reg_may_point_to_spin_lock(const struct bpf_reg_state *reg)
457457
map_value_has_spin_lock(reg->map_ptr);
458458
}
459459

460-
static bool reg_type_may_be_refcounted_or_null(enum bpf_reg_type type)
461-
{
462-
type = base_type(type);
463-
return type == PTR_TO_SOCKET || type == PTR_TO_TCP_SOCK ||
464-
type == PTR_TO_MEM || type == PTR_TO_BTF_ID;
465-
}
466-
467460
static bool type_is_rdonly_mem(u32 type)
468461
{
469462
return type & MEM_RDONLY;
@@ -875,7 +868,7 @@ static void print_verifier_state(struct bpf_verifier_env *env,
875868

876869
if (reg->id)
877870
verbose_a("id=%d", reg->id);
878-
if (reg_type_may_be_refcounted_or_null(t) && reg->ref_obj_id)
871+
if (reg->ref_obj_id)
879872
verbose_a("ref_obj_id=%d", reg->ref_obj_id);
880873
if (t != SCALAR_VALUE)
881874
verbose_a("off=%d", reg->off);

0 commit comments

Comments
 (0)