Function report |
Source Code:kernel\bpf\verifier.c |
Create Date:2022-07-28 12:59:13 |
| Last Modify:2022-05-19 20:02:10 | Copyright©Brick |
| home page | Tree |
| Annotation kernel can get tool activity | Download SCCT | Chinese |
Name:check_func_arg
Proto:static int check_func_arg(struct bpf_verifier_env *env, u32 regno, enum bpf_arg_type arg_type, struct bpf_call_arg_meta *meta)
Type:int
Parameter:
| Type | Parameter | Name |
|---|---|---|
| struct bpf_verifier_env * | env | |
| u32 | regno | |
| enum bpf_arg_type | arg_type | |
| struct bpf_call_arg_meta * | meta |
| 3411 | err = 0 |
| 3413 | If arg_type == unused argument in helper function Then Return 0 |
| 3416 | err = check_reg_arg(env, regno, register is used as source operand ) |
| 3420 | If arg_type == any (initialized) argument is ok Then |
| 3421 | If is_pointer_value(env, regno) Then |
| 3426 | Return 0 |
| 3429 | If type_is_pkt_pointer(type) && Not may_access_direct_pkt_data(env, meta, BPF_READ) Then |
| 3440 | If Does this register contain a constant zero? && arg_type == pointer to stack used as map value or NULL Then Else if Not type_is_pkt_pointer(type) && type != g points to map element value && type != expected_type Then |
| 3446 | Go to err_type |
| 3447 | Else if arg_type == umber of bytes accessed from memory || arg_type == umber of bytes accessed from memory or 0 Then |
| 3450 | If type != expected_type Then Go to err_type |
| 3452 | Else if arg_type == const argument used as pointer to bpf_map Then |
| 3454 | If type != expected_type Then Go to err_type |
| 3456 | Else if arg_type == pointer to context Then |
| 3458 | If type != expected_type Then Go to err_type |
| 3460 | err = check_ctx_reg(env, reg, regno) |
| 3463 | Else if arg_type == pointer to sock_common Then |
| 3466 | If Not type_is_sk_pointer(type) Then Go to err_type |
| 3469 | If ref_obj_id Then |
| 3470 | verbose(env, "verifier internal error: more than one arg with ref_obj_id R%d %u %u\n", regno, PTR_TO_SOCKET and PTR_TO_TCP_SOCK could be a ptr returned * from a pointer-cast helper, bpf_sk_fullsock() and * bpf_tcp_sock(). * Consider the following where "sk" is a reference counted * pointer returned from "sk = bpf_sk_lookup_tcp();": * 1: sk = bpf_s, ref_obj_id) |
| 3473 | Return -EFAULT |
| 3477 | Else if arg_type == pointer to bpf_sock (fullsock) Then |
| 3479 | If type != expected_type Then Go to err_type |
| 3481 | Else if arg_type == pointer to in-kernel struct Then |
| 3483 | If type != expected_type Then Go to err_type |
| 3485 | If for PTR_TO_BTF_ID != btf_id Then |
| 3486 | verbose(env, "Helper has type %s got %s in R%d\n", kernel_type_name(btf_id), kernel_type_name( for PTR_TO_BTF_ID ), regno) |
| 3490 | Return -EACCES |
| 3492 | If Not Returns true if @a is a known constant || value || Fixed part of pointer offset, pointer types only Then |
| 3497 | Else if arg_type == pointer to bpf_spin_lock Then |
| 3498 | If func_id == BPF_FUNC_spin_lock Then |
| 3501 | Else if func_id == BPF_FUNC_spin_unlock Then |
| 3504 | Else |
| 3508 | Else if arg_type_is_mem_ptr(arg_type) Then |
| 3514 | If Does this register contain a constant zero? && arg_type == pointer to valid memory or NULL Then Else if Not type_is_pkt_pointer(type) && type != g points to map element value && type != expected_type Then |
| 3520 | Go to err_type |
| 3522 | Else if arg_type_is_int_ptr(arg_type) Then |
| 3524 | If Not type_is_pkt_pointer(type) && type != g points to map element value && type != expected_type Then Go to err_type |
| 3528 | Else |
| 3533 | If arg_type == const argument used as pointer to bpf_map Then |
| 3536 | Else if arg_type == pointer to stack used as map key Then |
| 3541 | If Not map_ptr Then |
| 3560 | If Not map_ptr Then |
| 3569 | Else if arg_type_is_mem_size(arg_type) Then |
| 3581 | If Not Returns true if @a is a known constant Then meta = NULL |
| 3589 | If minimum possible (s64)value < 0 Then |
| 3592 | Return -EACCES |
| 3595 | If minimum possible (u64)value == 0 Then |
| 3596 | err = check_helper_mem_access(env, regno - 1, 0, zero_size_allowed, meta) |
| 3606 | Return -EACCES |
| 3608 | err = check_helper_mem_access(env, regno - 1, maximum possible (u64)value , zero_size_allowed, meta) |
| 3611 | If Not err Then err = mark_chain_precision(env, regno) |
| 3613 | Else if arg_type_is_int_ptr(arg_type) Then |
| 3614 | size = int_ptr_type_to_size(arg_type) |
| 3616 | err = check_helper_mem_access(env, regno, size, TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., meta) |
| 3619 | err = check_ptr_alignment(env, reg, 0, size, true) |
| 3622 | Return err |
| 3623 | err_type : |
| 3624 | verbose(env, "R%d type=%s expected=%s\n", regno, string representation of 'enum bpf_reg_type' [type], string representation of 'enum bpf_reg_type' [expected_type]) |
| 3626 | Return -EACCES |
| Name | Describe |
|---|---|
| check_helper_call |
| 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 |