Skip to content

Commit 3fab84f

Browse files
Martin KaFai LauAlexei Starovoitov
authored andcommitted
bpf: Simplify reg0 marking for the list kfuncs that return a bpf_list_node pointer
The next patch will add bpf_list_{front,back} kfuncs to peek the head and tail of a list. Both of them will return a 'struct bpf_list_node *'. Follow the earlier change for rbtree, this patch checks the return btf type is a 'struct bpf_list_node' pointer instead of checking each kfuncs individually to decide if mark_reg_graph_node should be called. This will make the bpf_list_{front,back} kfunc addition easier in the later patch. Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 47ada65 commit 3fab84f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

kernel/bpf/verifier.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11992,6 +11992,11 @@ static bool is_rbtree_node_type(const struct btf_type *t)
1199211992
return t == btf_type_by_id(btf_vmlinux, kf_arg_btf_ids[KF_ARG_RB_NODE_ID]);
1199311993
}
1199411994

11995+
static bool is_list_node_type(const struct btf_type *t)
11996+
{
11997+
return t == btf_type_by_id(btf_vmlinux, kf_arg_btf_ids[KF_ARG_LIST_NODE_ID]);
11998+
}
11999+
1199512000
static bool is_kfunc_arg_callback(struct bpf_verifier_env *env, const struct btf *btf,
1199612001
const struct btf_param *arg)
1199712002
{
@@ -13764,8 +13769,7 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
1376413769
insn_aux->kptr_struct_meta =
1376513770
btf_find_struct_meta(meta.arg_btf,
1376613771
meta.arg_btf_id);
13767-
} else if (meta.func_id == special_kfunc_list[KF_bpf_list_pop_front] ||
13768-
meta.func_id == special_kfunc_list[KF_bpf_list_pop_back]) {
13772+
} else if (is_list_node_type(ptr_type)) {
1376913773
struct btf_field *field = meta.arg_list_head.field;
1377013774

1377113775
mark_reg_graph_node(regs, BPF_REG_0, &field->graph_root);

0 commit comments

Comments
 (0)