函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\btf.c Create Date:2022-07-27 14:38:51
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:btf_struct_access

函数原型:int btf_struct_access(struct bpf_verifier_log *log, const struct btf_type *t, int off, int size, enum bpf_access_type atype, u32 *next_btf_id)

返回类型:int

参数:

类型参数名称
struct bpf_verifier_log *log
const struct btf_type *t
intoff
intsize
enum bpf_access_typeatype
u32 *next_btf_id
3732  msize等于0, total_nelems等于0
3733  const struct btf_type * mtype, * elem_type = NULL
3737  again :
3738  tname等于__btf_name_by_offset(btf_vmlinux, name_off)
3739  如果非 is only a special case of struct:* all its offsetof(member) == 0
3740  bpf_log(log, "Type '%s' is not a struct", tname)
3741  返回:负EINVAL
3745  如果btf_member_bitfield_size(t, member)则继续下一循环
3750  moff等于btf_member_bit_offset(t, member)除8
3751  如果offsize小于等于moff退出
3755  如果off小于moff则继续下一循环
3759  mtype等于btf_type_by_id(btf_vmlinux, type)
3760  mname等于__btf_name_by_offset(btf_vmlinux, name_off)
3762  mtype等于Resolve the size of a passed-in "type"* return type: type "u32[x][y]", i.e. BTF_KIND_ARRAY,* *type_size: (x * y * sizeof(u32)). Hence, *type_size always* corresponds to the return type.* *elem_type: u32* *total_nelems: (x * y)
3764  如果是错误
3765  bpf_log(log, "field %s doesn't have size\n", mname)
3766  返回:负EFAULT
3769  mtrue_end等于moffmsize
3770  如果off大于等于mtrue_end则继续下一循环
3774  如果btf_type_is_array(mtype)则
3818  如果moff恒等于mtrue_end则继续下一循环
3821  msize除等于total_nelems
3822  elem_idx等于offmoff的差除msize
3823  moff加等于elem_idxmsize
3824  mtype等于elem_type
3832  t等于mtype
3835  off减等于moff
3836  转到:again
3839  如果btf_type_is_ptr(mtype)则
3842  如果msize不等于sizeoff不等于moff
3843  bpf_log(log, "cannot access ptr member %s with moff %u in struct %s with off %u size %u\n", mname, moff, tname, off, size)
3846  返回:负EACCES
3854  next_btf_id等于type
3865  如果offsize大于mtrue_end
3866  bpf_log(log, "access beyond the end of member %s (mend:%u) in struct %s with off %u size %u\n", mname, mtrue_end, tname, off, size)
3869  返回:负EACCES
3872  返回:g doesn't contain a valid pointer
3874  bpf_log(log, "struct %s doesn't have field at offset %d\n", tname, off)
3875  返回:负EINVAL
调用者
名称描述
check_ptr_to_btf_access