函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\verifier.c Create Date:2022-07-27 14:16:58
Last Modify:2022-05-19 20:02:10 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:check_btf_func

函数原型:static int check_btf_func(struct bpf_verifier_env *env, const union bpf_attr *attr, union bpf_attr __user *uattr)

返回类型:int

参数:

类型参数名称
struct bpf_verifier_env *env
const union bpf_attr *attr
union bpf_attr __user *uattr
6669  krec_size等于sizeof(structbpf_func_info)
6671  struct bpf_func_info_aux * info_aux = NULL
6675  __userurecord
6676  prev_offset等于0
6677  ret等于0
6679  nfuncs等于 number of bpf_func_info records
6680  如果非nfuncs则返回:0
6683  如果nfuncs不等于subprog_cnt
6684  verbose(env, "number of funcs in func_info doesn't match number of subprogs\n")
6685  返回:负EINVAL
6688  urec_size等于 userspace bpf_func_info size
6689  如果urec_size小于The minimum supported BTF func info size urec_size大于MAX_FUNCINFO_REC_SIZEurec_size取模sizeof(u32)则
6692  verbose(env, "invalid func info rec size %u\n", urec_size)
6693  返回:负EINVAL
6696  prog等于BPF program being verified
6697  btf等于btf
6699  urecord等于u64_to_user_ptr(func_info)
6700  min_size等于min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, krec_size, urec_size)
6702  krecord等于kvcalloc(nfuncs, krec_size, GFP_KERNEL | DOC: Action modifiers* Action modifiers* ~~~~~~~~~~~~~~~~* %__GFP_NOWARN suppresses allocation failure reports.* %__GFP_COMP address compound page metadata.* %__GFP_ZERO returns a zeroed page on success.)
6703  如果非krecord则返回:负ENOMEM
6705  info_aux等于分配数组内存并置零
6706  如果非info_aux则转到:err_free
6709 i小于nfuncs循环
6710  ret等于If we're handed a bigger struct than we know of, ensure all the unknown bits* are 0 - i.e. new user-space does not rely on any kernel feature extensions* we don't know about yet.* There is a ToCToU between this function call and the following
6711  如果ret
6712  如果ret恒等于负E2BIG
6713  verbose(env, "nonzero tailing record in func info")
6720  转到:err_free
6723  如果copy_from_user( & krecord[i], urecord, min_size)则
6724  ret等于负EFAULT
6725  转到:err_free
6729  如果i恒等于0则
6730  如果insn_off
6731  verbose(env, "nonzero insn_off %u for the first func info record", insn_off)
6734  ret等于负EINVAL
6735  转到:err_free
6737  否则如果insn_off小于等于prev_offset
6738  verbose(env, "same or smaller insn offset (%u) than previous func info record (%u)", insn_off, prev_offset)
6741  ret等于负EINVAL
6742  转到:err_free
6746  verbose(env, "func_info BTF section doesn't match subprog layout in BPF program\n")
6747  ret等于负EINVAL
6748  转到:err_free
6752  type等于btf_type_by_id(btf, type_id)
6754  verbose(env, "invalid type id %d in func info", type_id)
6756  ret等于负EINVAL
6757  转到:err_free
6759  prev_offset等于insn_off
6760  urecord加等于urec_size
6763  func_info等于krecord
6764  func_info_cnt等于nfuncs
6765  func_info_aux等于info_aux
6766  返回:0
6768  err_free :
6769  kvfree(krecord)
6770  kfree(info_aux)
6771  返回:ret
调用者
名称描述
check_btf_info