函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:check_attach_btf_id

函数原型:static int check_attach_btf_id(struct bpf_verifier_env *env)

返回类型:int

参数:

类型参数名称
struct bpf_verifier_env *env
9518  prog等于BPF program being verified
9519  tgt_prog等于linked_prog
9520  btf_id等于 in-kernel BTF type id to attach to
9521  prefix[]等于"btf_trace_"
9522  ret等于0, subprog等于负1
9525  bool conservative = true
9531  如果 Type of BPF program 不等于BPF_PROG_TYPE_TRACING则返回:0
9534  如果非btf_id
9535  verbose(env, "Tracing programs must provide btf_id\n")
9536  返回:负EINVAL
9538  btf等于bpf_prog_get_target_btf(prog)
9539  如果非btf
9540  verbose(env, "FENTRY/FEXIT program can only be attached to another program annotated with BTF\n")
9542  返回:负EINVAL
9544  t等于btf_type_by_id(btf, btf_id)
9545  如果非t
9546  verbose(env, "attach_btf_id %u is invalid\n", btf_id)
9547  返回:负EINVAL
9549  tname等于btf_name_by_offset(btf, name_off)
9550  如果非tname
9551  verbose(env, "attach_btf_id %u doesn't have a name\n", btf_id)
9552  返回:负EINVAL
9554  如果tgt_prog
9555  aux等于 Auxiliary fields
9557 i小于func_info_cnt循环如果type_id恒等于btf_id
9559  subprog等于i
9560  退出
9562  如果subprog恒等于负1则
9563  verbose(env, "Subprog %s doesn't exist\n", tname)
9564  返回:负EINVAL
9566  conservative等于unreliable
9567  key等于id左移32位按位或btf_id
9568  否则
9569  key等于btf_id
9574  如果tgt_prog
9575  verbose(env, "Only FENTRY/FEXIT progs are attachable to another BPF prog\n")
9577  返回:负EINVAL
9579  如果非btf_type_is_typedef(t)则
9580  verbose(env, "attach_btf_id %u is not a typedef\n", btf_id)
9582  返回:负EINVAL
9584  如果字符串指定长度比较
9585  verbose(env, "attach_btf_id %u points to wrong type name %s\n", btf_id, tname)
9587  返回:负EINVAL
9589  tname加等于prefix的长度减1
9590  t等于btf_type_by_id(btf, type)
9591  如果非btf_type_is_ptr(t)则返回:负EINVAL
9594  t等于btf_type_by_id(btf, type)
9595  如果非btf_type_is_func_proto(t)则返回:负EINVAL
9605  返回:0
9606  : For some prog types 恒等于BPF_TRACE_FENTRY
9608  如果非btf_type_is_func(t)则
9609  verbose(env, "attach_btf_id %u is not a function\n", btf_id)
9611  返回:负EINVAL
9613  t等于btf_type_by_id(btf, type)
9614  如果非btf_type_is_func_proto(t)则返回:负EINVAL
9617  如果非tr则返回:负ENOMEM
9623  如果addr
9624  trampoline等于tr
9625  转到:out
9627  如果tgt_progconservative
9631  ret等于btf_distill_func_proto( & log, btf, t, tname, & model)
9633  如果ret小于0则转到:out
9635  如果tgt_prog
9636  如果非 Is our filter JIT'ed?
9638  verbose(env, "Can trace only JITed BPF progs\n")
9639  ret等于负EINVAL
9640  转到:out
9644  verbose(env, "Cannot recursively attach\n")
9645  ret等于负EINVAL
9646  转到:out
9648  如果subprog恒等于0则addr等于bpf_func
9650  否则addr等于bpf_func
9652  否则
9654  如果非addr
9655  verbose(env, "The address of function %s cannot be found\n", tname)
9658  ret等于负ENOENT
9659  转到:out
9662  addr等于addr
9663  trampoline等于tr
9664  out :
9666  如果retbpf_trampoline_put(tr)
9668  返回:ret
9669  默认
9670  返回:负EINVAL
调用者
名称描述
bpf_check