Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 12:58:39 |
Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
home page | Tree |
Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:heck whether memory at (regno + off) is accessible for t = (read | write)* if t==write, value_regno is a register which value is stored into memory* if t==read, value_regno is a register which will receive the value from memory* if t==write &&
Proto:static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regno, int off, int bpf_size, enum bpf_access_type t, int value_regno, bool strict_alignment_once)
Type:int
Parameter:
Type | Parameter | Name |
---|---|---|
struct bpf_verifier_env * | env | |
int | insn_idx | |
u32 | regno | |
int | off | |
int | bpf_size | |
enum bpf_access_type | t | |
int | value_regno | |
bool | strict_alignment_once |
2909 | err = 0 |
2911 | size = bpf_size_to_bytes(bpf_size) |
2916 | err = check_ptr_alignment(env, reg, off, size, strict_alignment_once) |
2924 | If t == BPF_WRITE && value_regno >= 0 && is_pointer_value(env, value_regno) Then |
2926 | verbose(env, "R%d leaks addr into map\n", value_regno) |
2927 | Return -EACCES |
2933 | If Not err && t == BPF_READ && value_regno >= 0 Then |
2937 | If Returns true if @a is a known constant && bpf_map_is_rdonly(map) && map_direct_value_addr Then |
2941 | val = 0 |
2950 | Else |
2951 | mark_reg_unknown(env, regs, value_regno) |
2954 | Else if Ordering of fields matters. See states_equal() == g points to bpf_context Then |
2956 | btf_id = 0 |
2958 | If t == BPF_WRITE && value_regno >= 0 && is_pointer_value(env, value_regno) Then |
2960 | verbose(env, "R%d leaks addr into ctx\n", value_regno) |
2961 | Return -EACCES |
2964 | err = check_ctx_reg(env, reg, regno) |
2969 | If err Then verbose_linfo(env, insn_idx, "; ") |
2971 | If Not err && t == BPF_READ && value_regno >= 0 Then |
2976 | If reg_type == g doesn't contain a valid pointer Then |
2977 | mark_reg_unknown(env, regs, value_regno) |
2978 | Else |
2979 | mark_reg_known_zero(env, regs, value_regno) |
2989 | If reg_type == g points to kernel struct Then for PTR_TO_BTF_ID = btf_id |
2995 | Else if Ordering of fields matters. See states_equal() == g == frame_pointer + offset Then |
3002 | err = update_stack_depth(env, state, off) |
3006 | If t == BPF_WRITE Then err = heck_stack_read/write functions track spill/fill of registers,* stack boundary and alignment are checked in check_mem_access() |
3009 | Else err = check_stack_read(env, state, off, size, value_regno) |
3012 | Else if reg_is_pkt_pointer(reg) Then |
3017 | If t == BPF_WRITE && value_regno >= 0 && is_pointer_value(env, value_regno) Then |
3019 | verbose(env, "R%d leaks addr into packet\n", value_regno) |
3021 | Return -EACCES |
3024 | If Not err && t == BPF_READ && value_regno >= 0 Then mark_reg_unknown(env, regs, value_regno) |
3026 | Else if Ordering of fields matters. See states_equal() == g points to bpf_flow_keys Then |
3027 | If t == BPF_WRITE && value_regno >= 0 && is_pointer_value(env, value_regno) Then |
3029 | verbose(env, "R%d leaks addr into flow keys\n", value_regno) |
3031 | Return -EACCES |
3034 | err = check_flow_keys_access(env, off, size) |
3035 | If Not err && t == BPF_READ && value_regno >= 0 Then mark_reg_unknown(env, regs, value_regno) |
3037 | Else if type_is_sk_pointer( Ordering of fields matters. See states_equal() ) Then |
3039 | verbose(env, "R%d cannot write into %s\n", regno, string representation of 'enum bpf_reg_type' [ Ordering of fields matters. See states_equal() ]) |
3041 | Return -EACCES |
3044 | If Not err && value_regno >= 0 Then mark_reg_unknown(env, regs, value_regno) |
3046 | Else if Ordering of fields matters. See states_equal() == g points to a writable raw tp's buffer Then |
3048 | If Not err && t == BPF_READ && value_regno >= 0 Then mark_reg_unknown(env, regs, value_regno) |
3050 | Else if Ordering of fields matters. See states_equal() == g points to kernel struct Then |
3051 | err = check_ptr_to_btf_access(env, regs, regno, off, size, t, value_regno) |
3053 | Else |
3054 | verbose(env, "R%d invalid mem access '%s'\n", regno, string representation of 'enum bpf_reg_type' [ Ordering of fields matters. See states_equal() ]) |
3056 | Return -EACCES |
3059 | If Not err && size < size of eBPF register in bytes && value_regno >= 0 && t == BPF_READ && Ordering of fields matters. See states_equal() == g doesn't contain a valid pointer Then |
3064 | Return err |
Name | Describe |
---|---|
check_xadd | |
check_helper_call | |
do_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 |