函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\syscall.c Create Date:2022-07-27 14:06:22
Last Modify:2022-05-19 18:06:12 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:bpf_prog_load

函数原型:static int bpf_prog_load(union bpf_attr *attr, union bpf_attr __user *uattr)

返回类型:int

参数:

类型参数名称
union bpf_attr *attr
union bpf_attr __user *uattr
1704  type等于 one of enum bpf_prog_type
1710  如果helper macro to check that unused fields 'union bpf_attr' are zero (BPF_PROG_LOAD)则返回:负EINVAL
1713  如果prog_flags按位与If BPF_F_STRICT_ALIGNMENT is used in BPF_PROG_LOAD command, the* verifier will perform strict alignment checking as if the kernel* has been built with CONFIG_EFFICIENT_UNALIGNED_ACCESS not set,* and NET_IP_ALIGN defined to 2.按位或If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the* verifier will allow any alignment whatsoever. On platforms* with strict alignment requirements for loads ands stores (such* as sparc and mips) the verifier validates that all loads and按位或The verifier internal test flag. Behavior is undefined 按位或BPF_F_TEST_RND_HI32 is used in BPF_PROG_LOAD command for testing purpose.* Verifier does sub-register def/use analysis and identifies instructions whose* def only matters for low 32-bit, high 32-bit is never referenced later的值的反则返回:负EINVAL
1719  如果非IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)且prog_flags按位与If BPF_F_ANY_ALIGNMENT is used in BPF_PROF_LOAD command, the* verifier will allow any alignment whatsoever. On platforms* with strict alignment requirements for loads ands stores (such* as sparc and mips) the verifier validates that all loads and且非操作权限检查则返回:负EPERM
1725  如果复制用户字符串小于0则返回:负EFAULT
1728  license[license的长度 - 1]等于0
1731  is_gpl等于license_is_gpl_compatible(license)
1733  如果insn_cnt恒等于0或insn_cnt大于如果操作权限检查yes. 1M insns 否则BPF_MAXINSNS则返回:负E2BIG
1736  如果type不等于BPF_PROG_TYPE_SOCKET_FILTERtype不等于BPF_PROG_TYPE_CGROUP_SKB且非操作权限检查则返回:负EPERM
1741  Initially all BPF programs could be loaded w/o specifying* expected_attach_type
1742  如果bpf_prog_load_check_attach(type, For some prog types expected attach type must be known at * load time to verify attach type specific parts of prog * (context accesses, allowed helpers, etc)., in-kernel BTF type id to attach to , 0 to attach to vmlinux )则返回:负EINVAL
1748  prog等于bpf_prog_alloc(bpf_prog_size(insn_cnt), GFP_USER)
1749  如果非prog则返回:负ENOMEM
1752  For some prog types 等于 For some prog types expected attach type must be known at * load time to verify attach type specific parts of prog * (context accesses, allowed helpers, etc).
1753  in-kernel BTF type id to attach to 等于 in-kernel BTF type id to attach to
1754  如果 0 to attach to vmlinux
1757  tgt_prog等于bpf_prog_get( 0 to attach to vmlinux )
1758  如果是错误
1759  err等于错误
1760  转到:free_prog_nouncharge
1762  linked_prog等于tgt_prog
1765  offload_requested等于非非 ifindex of netdev to prep for
1767  err等于security_bpf_prog_alloc( Auxiliary fields )
1768  如果err则转到:free_prog_nouncharge
1771  err等于bpf_prog_charge_memlock(prog)
1772  如果err则转到:free_prog_sec
1775  Number of filter blocks 等于insn_cnt
1777  err等于负EFAULT
1778  如果copy_from_user(insns, u64_to_user_ptr(insns), bpf_prog_insn_size(prog))不等于0则转到:free_prog
1782  Original BPF program = NULL
1783  Is our filter JIT'ed? 等于0
1785  atomic64_set( & refcnt, 1)
1786  Is filter GPL compatible? 等于如果is_gpl则1否则0
1788  如果bpf_prog_is_dev_bound( Auxiliary fields )则
1789  err等于bpf_prog_offload_init(prog, attr)
1790  如果err则转到:free_prog
1795  err等于find_prog_type(type, prog)
1796  如果err小于0则转到:free_prog
1799  ns since boottime 等于ktime_get_boottime_ns()
1800  err等于dst and src must have at least BPF_OBJ_NAME_LEN number of bytes.* Return 0 on success and < 0 on error.
1801  如果err则转到:free_prog
1805  err等于bpf_check( & prog, attr, uattr)
1806  如果err小于0则转到:free_used_maps
1809  prog等于pf_prog_select_runtime - select exec runtime for BPF program*@fp: bpf_prog populated with internal BPF program*@err: pointer to error variable* Try to JIT eBPF program, if JIT is not available, use interpreter.
1810  如果err小于0则转到:free_used_maps
1813  err等于bpf_prog_alloc_id(prog)
1814  如果err则转到:free_used_maps
1831  bpf_prog_kallsyms_add(prog)
1832  perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0)
1834  err等于bpf_prog_new_fd(prog)
1835  如果err小于0则bpf_prog_put(prog)
1837  返回:err
1839  free_used_maps :
1844  __bpf_prog_put_noref(prog, used by non-func prog as the number of func progs )
1845  返回:err
1846  free_prog :
1847  bpf_prog_uncharge_memlock(prog)
1848  free_prog_sec :
1849  security_bpf_prog_free( Auxiliary fields )
1850  free_prog_nouncharge :
1851  Free internal BPF program
1852  返回:err