Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:look for pseudo eBPF instructions that access map FDs and* replace them with actual map pointers

Proto:static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
8166  insn = insnsi
8167  insn_cnt = Number of filter blocks
8170  err = bpf_prog_calc_tag(BPF program being verified )
8171  If err Then Return err
8174  When i < insn_cnt cycle
8177  verbose(env, "BPF_LDX uses reserved fields\n")
8178  Return -EINVAL
8184  verbose(env, "BPF_STX uses reserved fields\n")
8185  Return -EINVAL
8188  If opcode == ( BPF_LD | BPF_IMM | double word (64-bit) ) Then
8194  If i == insn_cnt - 1 || opcode != 0 || dest register != 0 || source register != 0 || signed offset != 0 Then
8197  verbose(env, "invalid bpf_ld_imm64 insn\n")
8198  Return -EINVAL
8201  If source register == 0 Then Go to next_insn
8212  verbose(env, "unrecognized bpf_ld_imm64 insn\n")
8214  Return -EINVAL
8219  If IS_ERR(map) Then
8220  verbose(env, "fd %d is not pointing to valid bpf_map\n", signed immediate constant )
8222  Return PTR_ERR(map)
8226  If err Then
8227  fdput(f)
8228  Return err
8233  addr = map
8234  Else
8238  verbose(env, "direct value offset of %u is not allowed\n", off)
8239  fdput(f)
8240  Return -EINVAL
8243  If Not map_direct_value_addr Then
8244  verbose(env, "no direct value access support for this map type\n")
8245  fdput(f)
8246  Return -EINVAL
8250  If err Then
8251  verbose(env, "invalid access to map value pointer, value_size=%u off=%u\n", value_size, off)
8253  fdput(f)
8254  Return err
8258  addr += off
8265  When j < umber of used maps cycle
8268  fdput(f)
8269  Go to next_insn
8274  fdput(f)
8275  Return -E2BIG
8283  bpf_map_inc(map)
8290  verbose(env, "only one cgroup storage of each type is allowed\n")
8291  fdput(f)
8292  Return -EBUSY
8295  fdput(f)
8296  next_insn :
8297  insn++
8298  i++
8299  Continue
8303  If Not bpf_opcode_in_insntable( opcode ) Then
8304  verbose(env, "unknown opcode %02x\n", opcode )
8305  Return -EINVAL
8313  Return 0
Caller
NameDescribe
bpf_check