Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\verifier.c Create Date:2022-07-28 12:59:21
Last Modify:2022-05-19 20:02:10 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:check_map_func_compatibility

Proto:static int check_map_func_compatibility(struct bpf_verifier_env *env, struct bpf_map *map, int func_id)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
struct bpf_map *map
intfunc_id
3632  If Not map Then Return 0
3637  Case map_type == BPF_MAP_TYPE_PROG_ARRAY
3638  If func_id != BPF_FUNC_tail_call Then Go to error
3640  Break
3641  Case map_type == BPF_MAP_TYPE_PERF_EVENT_ARRAY
3642  If func_id != BPF_FUNC_perf_event_read && func_id != BPF_FUNC_perf_event_output && func_id != BPF_FUNC_skb_output && func_id != BPF_FUNC_perf_event_read_value Then Go to error
3647  Break
3648  Case map_type == BPF_MAP_TYPE_STACK_TRACE
3649  If func_id != BPF_FUNC_get_stackid Then Go to error
3651  Break
3652  Case map_type == BPF_MAP_TYPE_CGROUP_ARRAY
3653  If func_id != BPF_FUNC_skb_under_cgroup && func_id != BPF_FUNC_current_task_under_cgroup Then Go to error
3656  Break
3657  Case map_type == BPF_MAP_TYPE_CGROUP_STORAGE
3658  Case map_type == BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE
3659  If func_id != BPF_FUNC_get_local_storage Then Go to error
3661  Break
3662  Case map_type == BPF_MAP_TYPE_DEVMAP
3663  Case map_type == BPF_MAP_TYPE_DEVMAP_HASH
3664  If func_id != BPF_FUNC_redirect_map && func_id != BPF_FUNC_map_lookup_elem Then Go to error
3667  Break
3671  Case map_type == BPF_MAP_TYPE_CPUMAP
3672  If func_id != BPF_FUNC_redirect_map Then Go to error
3674  Break
3675  Case map_type == BPF_MAP_TYPE_XSKMAP
3676  If func_id != BPF_FUNC_redirect_map && func_id != BPF_FUNC_map_lookup_elem Then Go to error
3679  Break
3680  Case map_type == BPF_MAP_TYPE_ARRAY_OF_MAPS
3681  Case map_type == BPF_MAP_TYPE_HASH_OF_MAPS
3682  If func_id != BPF_FUNC_map_lookup_elem Then Go to error
3684  Break
3685  Case map_type == BPF_MAP_TYPE_SOCKMAP
3686  If func_id != BPF_FUNC_sk_redirect_map && func_id != BPF_FUNC_sock_map_update && func_id != BPF_FUNC_map_delete_elem && func_id != BPF_FUNC_msg_redirect_map Then Go to error
3691  Break
3692  Case map_type == BPF_MAP_TYPE_SOCKHASH
3693  If func_id != BPF_FUNC_sk_redirect_hash && func_id != BPF_FUNC_sock_hash_update && func_id != BPF_FUNC_map_delete_elem && func_id != BPF_FUNC_msg_redirect_hash Then Go to error
3698  Break
3699  Case map_type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY
3700  If func_id != BPF_FUNC_sk_select_reuseport Then Go to error
3702  Break
3703  Case map_type == BPF_MAP_TYPE_QUEUE
3704  Case map_type == BPF_MAP_TYPE_STACK
3705  If func_id != BPF_FUNC_map_peek_elem && func_id != BPF_FUNC_map_pop_elem && func_id != BPF_FUNC_map_push_elem Then Go to error
3709  Break
3710  Case map_type == BPF_MAP_TYPE_SK_STORAGE
3711  If func_id != BPF_FUNC_sk_storage_get && func_id != BPF_FUNC_sk_storage_delete Then Go to error
3714  Break
3715  Default
3716  Break
3721  Case func_id == BPF_FUNC_tail_call
3722  If map_type != BPF_MAP_TYPE_PROG_ARRAY Then Go to error
3724  If subprog_cnt > 1 Then
3725  verbose(env, "tail_calls are not allowed in programs with bpf-to-bpf calls\n")
3726  Return -EINVAL
3728  Break
3729  Case func_id == BPF_FUNC_perf_event_read
3730  Case func_id == BPF_FUNC_perf_event_output
3731  Case func_id == BPF_FUNC_perf_event_read_value
3732  Case func_id == BPF_FUNC_skb_output
3733  If map_type != BPF_MAP_TYPE_PERF_EVENT_ARRAY Then Go to error
3735  Break
3736  Case func_id == BPF_FUNC_get_stackid
3737  If map_type != BPF_MAP_TYPE_STACK_TRACE Then Go to error
3739  Break
3740  Case func_id == BPF_FUNC_current_task_under_cgroup
3742  If map_type != BPF_MAP_TYPE_CGROUP_ARRAY Then Go to error
3744  Break
3751  Break
3752  Case func_id == BPF_FUNC_sk_redirect_map
3753  Case func_id == BPF_FUNC_msg_redirect_map
3755  If map_type != BPF_MAP_TYPE_SOCKMAP Then Go to error
3757  Break
3758  Case func_id == BPF_FUNC_sk_redirect_hash
3759  Case func_id == BPF_FUNC_msg_redirect_hash
3761  If map_type != BPF_MAP_TYPE_SOCKHASH Then Go to error
3763  Break
3768  Break
3772  Break
3773  Case func_id == BPF_FUNC_map_peek_elem
3774  Case func_id == BPF_FUNC_map_pop_elem
3779  Break
3780  Case func_id == BPF_FUNC_sk_storage_get
3782  If map_type != BPF_MAP_TYPE_SK_STORAGE Then Go to error
3784  Break
3785  Default
3786  Break
3789  Return 0
3790  error :
3791  verbose(env, "cannot pass map_type %d into func %s#%d\n", map_type, func_id_name(func_id), func_id)
3793  Return -EINVAL
Caller
NameDescribe
check_helper_call