Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 13:02:27 |
Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:-recursive depth-first-search to detect loops in BPF program* loop == back-edge in directed graph
Proto:static int check_cfg(struct bpf_verifier_env *env)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct bpf_verifier_env * | env |
6539 | insn_cnt = Number of filter blocks |
6541 | ret = 0 |
6544 | insn_state = insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL) |
6545 | If Not insn_state Then Return -ENOMEM |
6548 | insn_stack = insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL) |
6549 | If Not insn_stack Then |
6550 | kvfree(insn_state) |
6551 | Return -ENOMEM |
6554 | insn_state[0] = DISCOVERED |
6555 | insn_stack[0] = 0 |
6556 | cur_stack = 1 |
6558 | peek_stack : |
6559 | If cur_stack == 0 Then Go to check_state |
6561 | t = insn_stack[cur_stack - 1] |
6563 | If Instruction classes ( opcode ) == BPF_JMP || Instruction classes ( opcode ) == jmp mode in word width Then |
6565 | opcode = alu/jmp fields ( opcode ) |
6567 | If opcode == unction return Then |
6568 | Go to mark_explored |
6569 | Else if opcode == unction call Then |
6571 | If ret == 1 Then Go to peek_stack |
6575 | If t + 1 < insn_cnt Then init_explored_state(env, t + 1) |
6578 | init_explored_state(env, t) |
6581 | If ret == 1 Then Go to peek_stack |
6594 | If ret == 1 Then Go to peek_stack |
6602 | init_explored_state(env, t + signed offset + 1) |
6606 | If t + 1 < insn_cnt Then init_explored_state(env, t + 1) |
6608 | Else |
6610 | init_explored_state(env, t) |
6612 | If ret == 1 Then Go to peek_stack |
6618 | If ret == 1 Then Go to peek_stack |
6623 | Else |
6628 | If ret == 1 Then Go to peek_stack |
6634 | mark_explored : |
6635 | insn_state[t] = EXPLORED |
6636 | If cur_stack-- <= 0 Then |
6641 | Go to peek_stack |
6643 | check_state : |
6645 | If insn_state[i] != EXPLORED Then |
6651 | ret = 0 |
6653 | err_free : |
6654 | kvfree(insn_state) |
6655 | kvfree(insn_stack) |
6656 | insn_state = insn_stack = NULL |
6657 | Return ret |
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 |