Lines Matching refs:fn
6153 const struct bpf_func_proto *fn) in check_func_arg() argument
6157 enum bpf_arg_type arg_type = fn->arg_type[arg]; in check_func_arg()
6198 arg_btf_id = fn->arg_btf_id[arg]; in check_func_arg()
6337 fn->arg_size[arg], false, in check_func_arg()
6745 static bool check_raw_mode_ok(const struct bpf_func_proto *fn) in check_raw_mode_ok() argument
6749 if (fn->arg1_type == ARG_PTR_TO_UNINIT_MEM) in check_raw_mode_ok()
6751 if (fn->arg2_type == ARG_PTR_TO_UNINIT_MEM) in check_raw_mode_ok()
6753 if (fn->arg3_type == ARG_PTR_TO_UNINIT_MEM) in check_raw_mode_ok()
6755 if (fn->arg4_type == ARG_PTR_TO_UNINIT_MEM) in check_raw_mode_ok()
6757 if (fn->arg5_type == ARG_PTR_TO_UNINIT_MEM) in check_raw_mode_ok()
6767 static bool check_args_pair_invalid(const struct bpf_func_proto *fn, int arg) in check_args_pair_invalid() argument
6769 bool is_fixed = fn->arg_type[arg] & MEM_FIXED_SIZE; in check_args_pair_invalid()
6770 bool has_size = fn->arg_size[arg] != 0; in check_args_pair_invalid()
6773 if (arg + 1 < ARRAY_SIZE(fn->arg_type)) in check_args_pair_invalid()
6774 is_next_size = arg_type_is_mem_size(fn->arg_type[arg + 1]); in check_args_pair_invalid()
6776 if (base_type(fn->arg_type[arg]) != ARG_PTR_TO_MEM) in check_args_pair_invalid()
6782 static bool check_arg_pair_ok(const struct bpf_func_proto *fn) in check_arg_pair_ok() argument
6789 if (arg_type_is_mem_size(fn->arg1_type) || in check_arg_pair_ok()
6790 check_args_pair_invalid(fn, 0) || in check_arg_pair_ok()
6791 check_args_pair_invalid(fn, 1) || in check_arg_pair_ok()
6792 check_args_pair_invalid(fn, 2) || in check_arg_pair_ok()
6793 check_args_pair_invalid(fn, 3) || in check_arg_pair_ok()
6794 check_args_pair_invalid(fn, 4)) in check_arg_pair_ok()
6800 static bool check_btf_id_ok(const struct bpf_func_proto *fn) in check_btf_id_ok() argument
6804 for (i = 0; i < ARRAY_SIZE(fn->arg_type); i++) { in check_btf_id_ok()
6805 if (base_type(fn->arg_type[i]) == ARG_PTR_TO_BTF_ID && !fn->arg_btf_id[i]) in check_btf_id_ok()
6808 if (base_type(fn->arg_type[i]) != ARG_PTR_TO_BTF_ID && fn->arg_btf_id[i] && in check_btf_id_ok()
6810 (base_type(fn->arg_type[i]) != ARG_PTR_TO_MEM || in check_btf_id_ok()
6811 !(fn->arg_type[i] & MEM_FIXED_SIZE))) in check_btf_id_ok()
6818 static int check_func_proto(const struct bpf_func_proto *fn, int func_id) in check_func_proto() argument
6820 return check_raw_mode_ok(fn) && in check_func_proto()
6821 check_arg_pair_ok(fn) && in check_func_proto()
6822 check_btf_id_ok(fn) ? 0 : -EINVAL; in check_func_proto()
7526 const struct bpf_func_proto *fn = NULL; in check_helper_call() local
7544 fn = env->ops->get_func_proto(func_id, env->prog); in check_helper_call()
7545 if (!fn) { in check_helper_call()
7552 if (!env->prog->gpl_compatible && fn->gpl_only) { in check_helper_call()
7557 if (fn->allowed && !fn->allowed(env->prog)) { in check_helper_call()
7563 changes_data = bpf_helper_changes_pkt_data(fn->func); in check_helper_call()
7564 if (changes_data && fn->arg1_type != ARG_PTR_TO_CTX) { in check_helper_call()
7571 meta.pkt_access = fn->pkt_access; in check_helper_call()
7573 err = check_func_proto(fn, func_id); in check_helper_call()
7583 err = check_func_arg(env, i, &meta, fn); in check_helper_call()
7618 fn->arg_type[meta.uninit_dynptr_regno - BPF_REG_1], in check_helper_call()
7626 if (arg_type_is_dynptr(fn->arg_type[meta.release_regno - BPF_REG_1])) in check_helper_call()
7700 if (arg_type_is_dynptr(fn->arg_type[i])) { in check_helper_call()
7740 ret_type = fn->ret_type; in check_helper_call()
7834 if (fn->ret_btf_id == BPF_PTR_POISON) { in check_helper_call()
7841 ret_btf_id = *fn->ret_btf_id; in check_helper_call()
7882 do_refine_retval_range(regs, fn->ret_type, func_id, &meta); in check_helper_call()
14220 const struct bpf_func_proto *fn; in do_misc_fixups() local
14697 fn = env->ops->get_func_proto(insn->imm, env->prog); in do_misc_fixups()
14701 if (!fn->func) { in do_misc_fixups()
14707 insn->imm = fn->func - __bpf_call_base; in do_misc_fixups()