Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 13:00:29 |
Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:Handles arithmetic on a pointer and a scalar: computes new min/max and var_off.* Caller should also handle BPF_MOV case separately.* If we return -EACCES, caller may want to try again treating pointer as a* scalar
Proto:static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, struct bpf_insn *insn, const struct bpf_reg_state *ptr_reg, const struct bpf_reg_state *off_reg)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct bpf_verifier_env * | env | |
struct bpf_insn * | insn | |
const struct bpf_reg_state * | ptr_reg | |
const struct bpf_reg_state * | off_reg |
4567 | vstate = current verifier state |
4568 | state = call stack tracking [curframe] |
4571 | smin_val = minimum possible (s64)value , smax_val = maximum possible (s64)value , smin_ptr = minimum possible (s64)value , smax_ptr = maximum possible (s64)value |
4573 | umin_val = minimum possible (u64)value , umax_val = maximum possible (u64)value , umin_ptr = minimum possible (u64)value , umax_ptr = maximum possible (u64)value |
4575 | dst = dest register , src = source register |
4576 | opcode = alu/jmp fields ( opcode ) |
4587 | Return 0 |
4590 | If Instruction classes ( opcode ) != alu mode in double word width Then |
4595 | Return -EACCES |
4600 | verbose(env, "R%d pointer arithmetic on %s prohibited, null-check it first\n", dst, string representation of 'enum bpf_reg_type' [ Ordering of fields matters. See states_equal() ]) |
4602 | Return -EACCES |
4612 | verbose(env, "R%d pointer arithmetic on %s prohibited\n", dst, string representation of 'enum bpf_reg_type' [ Ordering of fields matters. See states_equal() ]) |
4614 | Return -EACCES |
4616 | If Not allow_ptr_leaks && Not known && smin_val < 0 != smax_val < 0 Then |
4622 | Default |
4623 | Break |
4629 | Ordering of fields matters. See states_equal() = Ordering of fields matters. See states_equal() |
4632 | If Not check_reg_sane_offset(env, off_reg, Ordering of fields matters. See states_equal() ) || Not check_reg_sane_offset(env, ptr_reg, Ordering of fields matters. See states_equal() ) Then Return -EINVAL |
4639 | If ret < 0 Then |
4654 | Fixed part of pointer offset, pointer types only = Fixed part of pointer offset, pointer types only + smin_val |
4656 | Break |
4667 | If signed_add_overflows(smin_ptr, smin_val) || signed_add_overflows(smax_ptr, smax_val) Then |
4671 | Else |
4672 | minimum possible (s64)value = smin_ptr + smin_val |
4673 | maximum possible (s64)value = smax_ptr + smax_val |
4677 | minimum possible (u64)value = 0 |
4679 | Else |
4680 | minimum possible (u64)value = umin_ptr + umin_val |
4681 | maximum possible (u64)value = umax_ptr + umax_val |
4684 | Fixed part of pointer offset, pointer types only = Fixed part of pointer offset, pointer types only |
4686 | If reg_is_pkt_pointer(ptr_reg) Then |
4689 | Max size from any of the above. = 0 |
4691 | Break |
4694 | If ret < 0 Then |
4722 | Fixed part of pointer offset, pointer types only = Fixed part of pointer offset, pointer types only - smin_val |
4724 | Break |
4729 | If signed_sub_overflows(smin_ptr, smax_val) || signed_sub_overflows(smax_ptr, smin_val) Then |
4734 | Else |
4735 | minimum possible (s64)value = smin_ptr - smax_val |
4736 | maximum possible (s64)value = smax_ptr - smin_val |
4740 | minimum possible (u64)value = 0 |
4742 | Else |
4744 | minimum possible (u64)value = umin_ptr - umax_val |
4745 | maximum possible (u64)value = umax_ptr - umin_val |
4748 | Fixed part of pointer offset, pointer types only = Fixed part of pointer offset, pointer types only |
4750 | If reg_is_pkt_pointer(ptr_reg) Then |
4753 | If smin_val < 0 Then Max size from any of the above. = 0 |
4756 | Break |
4761 | verbose(env, "R%d bitwise operator %s on pointer prohibited\n", dst, bpf_alu_string[opcode >> 4]) |
4763 | Return -EACCES |
4764 | Default |
4766 | verbose(env, "R%d pointer arithmetic with %s operator prohibited\n", dst, bpf_alu_string[opcode >> 4]) |
4768 | Return -EACCES |
4771 | If Not check_reg_sane_offset(env, dst_reg, Ordering of fields matters. See states_equal() ) Then Return -EINVAL |
4781 | If Not allow_ptr_leaks Then |
4784 | verbose(env, "R%d pointer arithmetic of map value goes out of range, prohibited for !root\n", dst) |
4786 | Return -EACCES |
4796 | Return 0 |
Name | Describe |
---|---|
adjust_reg_min_max_vals | Handles ALU ops other than BPF_END, BPF_NEG and BPF_MOV: computes new min/max* and var_off. |
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 |