Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 13:03:47 |
Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:do_check
Proto:static int do_check(struct bpf_verifier_env *env)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct bpf_verifier_env * | env |
7741 | insn_cnt = Number of filter blocks |
7742 | bool do_print_state = false |
7743 | prev_insn_idx = -1 |
7745 | prev_linfo = NULL |
7747 | state = 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). |
7750 | curframe = 0 |
7751 | speculative = false |
7753 | call stack tracking [0] = 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). |
7754 | If Not call stack tracking [0] Then |
7758 | current verifier state = state |
7759 | init_func_state(env, call stack tracking [0], BPF_MAIN_FUNC, 0, 0) |
7764 | If btf_check_func_arg_match(env, 0) Then Return -EINVAL |
7767 | cycle |
7772 | prev_insn_idx = prev_insn_idx |
7780 | class = Instruction classes ( opcode ) |
7782 | If ++umber of instructions analyzed by the verifier > yes. 1M insns Then |
7783 | verbose(env, "BPF program is too large. Processed %d insn\n", umber of instructions analyzed by the verifier ) |
7786 | Return -E2BIG |
7789 | err = is_state_visited(env, insn_idx) |
7792 | If err == 1 Then |
7794 | If level & BPF_LOG_LEVEL Then |
7795 | If do_print_state Then verbose(env, "\nfrom %d to %d%s: safe\n", prev_insn_idx, insn_idx, speculative ? " (speculative execution)" : "") |
7803 | Go to process_bpf_exit |
7806 | If signal_pending(current process) Then Return -EAGAIN |
7809 | If need_resched() Then cond_resched() |
7812 | If level & BPF_LOG_LEVEL2 || level & BPF_LOG_LEVEL && do_print_state Then |
7814 | If level & BPF_LOG_LEVEL2 Then verbose(env, "%d:", insn_idx) |
7816 | Else verbose(env, "\nfrom %d to %d%s:", prev_insn_idx, insn_idx, speculative ? " (speculative execution)" : "") |
7822 | do_print_state = false |
7825 | If level & BPF_LOG_LEVEL Then |
7826 | const struct bpf_insn_cbs cbs = {cb_print = verbose, private_data = env, } |
7831 | verbose_linfo(env, insn_idx, "; ") |
7833 | print_bpf_insn( & cbs, insn, allow_ptr_leaks) |
7836 | If bpf_prog_is_dev_bound( Auxiliary fields ) Then |
7837 | err = bpf_prog_offload_verify_insn(env, insn_idx, prev_insn_idx) |
7844 | this insn was processed by the verifier = true |
7845 | prev_insn_idx = insn_idx |
7847 | If class == BPF_ALU || class == alu mode in double word width Then |
7862 | err = check_reg_arg(env, dest register , DST_OP_NO_MARK) |
7879 | If prev_src_type == hing was written into register Then |
7884 | prev_src_type = src_reg_type |
7901 | If BPF BPF_DW 0x18 64-bit ( opcode ) == xclusive add Then |
7929 | If prev_dst_type == hing was written into register Then |
7930 | prev_dst_type = dst_reg_type |
7937 | If BPF BPF_DW 0x18 64-bit ( opcode ) != BPF_MEM || source register != BPF_REG_0 Then |
7947 | If is_ctx_reg(env, dest register ) Then |
7948 | verbose(env, "BPF_ST stores into R%d %s is not allowed\n", dest register , string representation of 'enum bpf_reg_type' [type]) |
7951 | Return -EACCES |
7961 | Else if class == BPF_JMP || class == jmp mode in word width Then |
7962 | opcode = alu/jmp fields ( opcode ) |
7965 | If opcode == unction call Then |
7966 | If BPF_SRC( opcode ) != BPF_K || signed offset != 0 || source register != BPF_REG_0 && source register != when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative* offset to another bpf function || dest register != BPF_REG_0 || class == jmp mode in word width Then |
7982 | If source register == when bpf_call->src_reg == BPF_PSEUDO_CALL, bpf_call->imm == pc-relative* offset to another bpf function Then err = check_func_call(env, insn, & insn_idx) |
7984 | Else err = check_helper_call(env, signed immediate constant , insn_idx) |
7990 | If BPF_SRC( opcode ) != BPF_K || signed immediate constant != 0 || source register != BPF_REG_0 || dest register != BPF_REG_0 || class == jmp mode in word width Then |
7999 | insn_idx += signed offset + 1 |
8000 | Continue |
8002 | Else if opcode == unction return Then |
8003 | If BPF_SRC( opcode ) != BPF_K || signed immediate constant != 0 || source register != BPF_REG_0 || dest register != BPF_REG_0 || class == jmp mode in word width Then |
8012 | If active_spin_lock Then |
8017 | If curframe Then |
8026 | err = check_reference_leak(env) |
8040 | If is_pointer_value(env, BPF_REG_0) Then |
8045 | err = check_return_code(env) |
8048 | process_bpf_exit : |
8050 | err = pop_stack(env, & prev_insn_idx, & insn_idx) |
8052 | If err < 0 Then |
8056 | Else |
8057 | do_print_state = true |
8058 | Continue |
8060 | Else |
8066 | mode = BPF BPF_DW 0x18 64-bit ( opcode ) |
8078 | insn_idx++ |
8079 | this insn was processed by the verifier = true |
8080 | Else |
8084 | Else |
8089 | insn_idx++ |
8093 | Return 0 |
Name | Describe |
---|---|
bpf_check |
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 |