Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\verifier.c Create Date:2022-07-28 13:02:44
Last Modify:2022-05-19 20:02:10 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:check_btf_line

Proto:static int check_btf_line(struct bpf_verifier_env *env, const union bpf_attr *attr, union bpf_attr __user *uattr)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
const union bpf_attr *attr
union bpf_attr __user *uattr
6794  prev_offset = 0
6799  __user * ulinfo
6802  nr_linfo = number of bpf_line_info records
6803  If Not nr_linfo Then Return 0
6806  rec_size = userspace bpf_line_info size
6807  If rec_size < MIN_BPF_LINEINFO_SIZE || rec_size > MAX_LINEINFO_REC_SIZE || rec_size & sizeof(u32) - 1 Then Return -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  If Not linfo Then Return -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  When i < nr_linfo cycle
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  If err Then
6831  If err == -E2BIG Then
6832  verbose(env, "nonzero tailing record in line_info")
6837  Go to err_free
6840  If copy_from_user( & linfo[i], ulinfo, ncopy) Then
6841  err = -EFAULT
6842  Go to err_free
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  Go to err_free
6865  If Not opcode Then
6866  verbose(env, "Invalid insn code at line_info[%u].insn_off\n", i)
6869  err = -EINVAL
6870  Go to err_free
6875  verbose(env, "Invalid line_info[%u].line_off or .file_name_off\n", i)
6876  err = -EINVAL
6877  Go to err_free
6880  If s != subprog_cnt Then
6885  verbose(env, "missing bpf_line_info for func#%u\n", s)
6886  err = -EINVAL
6887  Go to err_free
6891  prev_offset = insn_off
6892  ulinfo += rec_size
6895  If s != subprog_cnt Then
6896  verbose(env, "missing bpf_line_info for %u funcs starting from func#%u\n", subprog_cnt - s, s)
6898  err = -EINVAL
6899  Go to 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  Return 0
6907  err_free :
6908  kvfree(linfo)
6909  Return err
Caller
NameDescribe
check_btf_info