Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 13:06:00 |
Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:bpf_check
Proto:int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, union bpf_attr __user *uattr)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct bpf_prog ** | prog | |
union bpf_attr * | attr | |
union bpf_attr __user * | uattr |
9677 | start_time = ktime_get_ns() |
9684 | If ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(bpf_verifier_ops) == 0 Then Return -EINVAL |
9690 | env = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc). |
9695 | len = Number of filter blocks |
9699 | If Not array of per-insn state Then Go to err_free_env |
9701 | When i < len cycle original instruction index = i |
9703 | BPF program being verified = prog |
9704 | ops = bpf_verifier_ops[ Type of BPF program ] |
9705 | is_priv = Check operation authority |
9708 | mutex_lock( & bpf_verifier_lock) |
9709 | If Not btf_vmlinux Then btf_vmlinux = btf_parse_vmlinux() |
9715 | If Not is_priv Then mutex_lock( & bpf_verifier_lock) |
9718 | If verbosity level of verifier || log_buf || size of user buffer Then |
9722 | level = verbosity level of verifier |
9724 | len_total = size of user buffer |
9728 | If len_total < 128 || len_total > UINT_MAX >> 2 || Not level || Not ubuf || level & ~BPF_LOG_MASK Then Go to err_unlock |
9733 | If IS_ERR(btf_vmlinux) Then |
9736 | ret = PTR_ERR(btf_vmlinux) |
9737 | Go to skip_full_check |
9740 | ret = check_attach_btf_id(env) |
9741 | If ret Then Go to skip_full_check |
9745 | If Not IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) Then perform strict pointer alignment checks = true |
9750 | allow_ptr_leaks = is_priv |
9752 | If is_priv Then st verifier with different pruning frequency = prog_flags & The verifier internal test flag. Behavior is undefined |
9755 | ret = look for pseudo eBPF instructions that access map FDs and* replace them with actual map pointers |
9756 | If ret < 0 Then Go to skip_full_check |
9759 | If bpf_prog_is_dev_bound( Auxiliary fields ) Then |
9761 | If ret Then Go to skip_full_check |
9765 | search pruning optimization = kvcalloc(state_htab_size(env), size of * , GFP_USER) |
9769 | If Not search pruning optimization Then Go to skip_full_check |
9772 | ret = check_subprogs(env) |
9773 | If ret < 0 Then Go to skip_full_check |
9776 | ret = check_btf_info(env, attr, uattr) |
9777 | If ret < 0 Then Go to skip_full_check |
9780 | ret = -recursive depth-first-search to detect loops in BPF program* loop == back-edge in directed graph |
9781 | If ret < 0 Then Go to skip_full_check |
9785 | If current verifier state Then |
9786 | free_verifier_state(current verifier state , true) |
9787 | current verifier state = NULL |
9790 | If ret == 0 && bpf_prog_is_dev_bound( Auxiliary fields ) Then ret = bpf_prog_offload_finalize(env) |
9793 | skip_full_check : |
9795 | free_states(env) |
9797 | If ret == 0 Then ret = starting from main bpf function walk all instructions of the function* and recursively walk all callees that given function can call |
9801 | If is_priv Then |
9802 | If ret == 0 Then opt_hard_wire_dead_code_branches(env) |
9804 | If ret == 0 Then ret = opt_remove_dead_code(env) |
9806 | If ret == 0 Then ret = opt_remove_nops(env) |
9808 | Else |
9823 | If ret == 0 && Not bpf_prog_is_dev_bound( Auxiliary fields ) Then |
9824 | ret = opt_subreg_zext_lo32_rnd_hi32(env, attr) |
9829 | If ret == 0 Then ret = fixup_call_args(env) |
9832 | al verification time = ktime_get_ns() - start_time |
9833 | print_verification_stats(env) |
9835 | If level && bpf_verifier_log_full(log) Then ret = -ENOSPC |
9839 | Go to err_release_maps |
9842 | If ret == 0 && umber of used maps Then |
9844 | used_maps = kmalloc_array - allocate memory for an array.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc). |
9848 | If Not used_maps Then |
9850 | Go to err_release_maps |
9853 | No 3D Now!(used_maps, array of map's used by eBPF program , size of array of map's used by eBPF program [0] * umber of used maps ) |
9855 | used_map_cnt = umber of used maps |
9863 | If ret == 0 Then adjust_btf_func(env) |
9866 | err_release_maps : |
9867 | If Not used_maps Then drop refcnt of maps used by the rejected program |
9872 | prog = BPF program being verified |
9873 | err_unlock : |
9876 | vfree(array of per-insn state ) |
9877 | err_free_env : |
9879 | Return ret |
Name | Describe |
---|---|
bpf_prog_load |
Source code conversion tool public plug-in interface | X |
---|---|
Support c/c++/esqlc/java Oracle/Informix/Mysql Plug-in can realize: logical Report Code generation and batch code conversion |