Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 13:04:45 |
| Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
| home page | Tree |
| Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:vert load instructions that access fields of a context type into a* sequence of instructions that access fields of the underlying structure:* struct __sk_buff -> struct sk_buff* struct bpf_sock_ops -> struct sock
Proto:static int convert_ctx_accesses(struct bpf_verifier_env *env)
Type:int
Parameter:
| Type | Parameter | Name |
|---|---|---|
| struct bpf_verifier_env * | env |
| 8749 | delta = 0 |
| 8750 | insn_cnt = Number of filter blocks |
| 8757 | If gen_prologue || seen_direct_write Then |
| 8777 | If bpf_prog_is_dev_bound( Auxiliary fields ) Then Return 0 |
| 8785 | If opcode == ( BPF_LDX | BPF_MEM | 8-bit ) || opcode == ( BPF_LDX | BPF_MEM | 16-bit ) || opcode == ( BPF_LDX | BPF_MEM | 32-bit ) || opcode == ( BPF_LDX | BPF_MEM | double word (64-bit) ) Then type = BPF_READ |
| 8790 | Else if opcode == ( BPF_STX | BPF_MEM | 8-bit ) || opcode == ( BPF_STX | BPF_MEM | 16-bit ) || opcode == ( BPF_STX | BPF_MEM | 32-bit ) || opcode == ( BPF_STX | BPF_MEM | double word (64-bit) ) Then type = BPF_WRITE |
| 8795 | Else Continue |
| 8798 | If type == BPF_WRITE && stack slot to be cleared Then |
| 8800 | struct bpf_insn patch[] = {Memory store, *(uint *) (dst_reg + off16) = imm32 (double word (64-bit) , BPF_REG_FP, stack slot to be cleared , 0), * insn, } |
| 8823 | Continue |
| 8827 | Case pointer type for load/store insns == g points to bpf_context |
| 8828 | If Not convert_ctx_access Then Continue |
| 8831 | Break |
| 8833 | Case pointer type for load/store insns == g points to sock_common |
| 8835 | Break |
| 8838 | Break |
| 8841 | Break |
| 8847 | opcode = BPF_LDX | unused opcode to mark special load instruction. Same as BPF_ABS | ld/ldx fields ( opcode ) |
| 8848 | num_exentries++ |
| 8849 | Continue |
| 8850 | Default |
| 8851 | Continue |
| 8855 | size = BPF_LDST_BYTES(insn) |
| 8862 | is_narrower_load = size < ctx_field_size |
| 8864 | off = signed offset |
| 8865 | If is_narrower_load Then |
| 8874 | If ctx_field_size == 4 Then size_code = 32-bit |
| 8876 | Else if ctx_field_size == 8 Then size_code = double word (64-bit) |
| 8879 | signed offset = off & ~(size_default - 1) |
| 8883 | target_size = 0 |
| 8884 | cnt = convert_ctx_access(type, insn, insn_buf, BPF program being verified , & target_size) |
| 8886 | If cnt == 0 || cnt >= ARRAY_SIZE - get the number of elements in array @arr*@arr: array to be sized(insn_buf) || ctx_field_size && Not target_size Then |
| 8892 | If is_narrower_load && size < target_size Then |
| 8893 | shift = bpf_ctx_narrow_access_offset(off, size, size_default) * 8 |
| 8895 | If ctx_field_size <= 4 Then |
| 8896 | If shift Then insn_buf[cnt++] = BPF_ALU32_IMM(BPF_RSH, dest register , shift) |
| 8900 | insn_buf[cnt++] = BPF_ALU32_IMM(BPF_AND, dest register , (1 << size * 8) - 1) |
| 8902 | Else |
| 8903 | If shift Then insn_buf[cnt++] = ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 (BPF_RSH, dest register , shift) |
| 8907 | insn_buf[cnt++] = ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 (BPF_AND, dest register , (1ULL << size * 8) - 1) |
| 8923 | 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 |