函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:check_btf_line

函数原型:static int check_btf_line(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
6794  prev_offset等于0
6799  __userulinfo
6802  nr_linfo等于 number of bpf_line_info records
6803  如果非nr_linfo则返回:0
6806  rec_size等于 userspace bpf_line_info size
6807  如果rec_size小于MIN_BPF_LINEINFO_SIZErec_size大于MAX_LINEINFO_REC_SIZErec_size按位与sizeof(u32)减1则返回:负EINVAL
6815  linfo等于kvcalloc(nr_linfo, sizeof(structbpf_line_info), 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.)
6817  如果非linfo则返回:负ENOMEM
6820  prog等于BPF program being verified
6821  btf等于btf
6823  s等于0
6824  sub等于subprog_info
6825  ulinfo等于u64_to_user_ptr(line_info)
6826  expected_size等于sizeof(structbpf_line_info)
6827  ncopy等于min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, expected_size, rec_size)
6828 i小于nr_linfo循环
6829  err等于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
6830  如果err
6831  如果err恒等于负E2BIG
6832  verbose(env, "nonzero tailing record in line_info")
6837  转到:err_free
6840  如果copy_from_user( & linfo[i], ulinfo, ncopy)则
6841  err等于负EFAULT
6842  转到:err_free
6856  如果iinsn_off小于等于prev_offsetinsn_off大于等于 Number of filter blocks
6858  verbose(env, "Invalid line_info[%u].insn_off:%u (prev_offset:%u prog->len:%u)\n", i, insn_off, prev_offset, Number of filter blocks )
6861  err等于负EINVAL
6862  转到:err_free
6865  如果非 opcode
6866  verbose(env, "Invalid insn code at line_info[%u].insn_off\n", i)
6869  err等于负EINVAL
6870  转到:err_free
6875  verbose(env, "Invalid line_info[%u].line_off or .file_name_off\n", i)
6876  err等于负EINVAL
6877  转到:err_free
6880  如果s不等于subprog_cnt
6883  s自加
6884  否则如果 insn idx of function entry point 小于insn_off
6885  verbose(env, "missing bpf_line_info for func#%u\n", s)
6886  err等于负EINVAL
6887  转到:err_free
6891  prev_offset等于insn_off
6892  ulinfo加等于rec_size
6895  如果s不等于subprog_cnt
6896  verbose(env, "missing bpf_line_info for %u funcs starting from func#%u\n", subprog_cnt - s, s)
6898  err等于负EINVAL
6899  转到:err_free
6902  bpf_line_info loaded from userspace. linfo->insn_off * has the xlated insn offset. * Both the main and sub prog share the same linfo. * The subprog can access its first linfo by * using the linfo_idx.等于linfo
6903  nr_linfo等于nr_linfo
6905  返回:0
6907  err_free :
6908  kvfree(linfo)
6909  返回:err
调用者
名称描述
check_btf_info