Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:vert load instructions that access fields of a context type into a* sequence of instructions that access fields of the underlying structure:* struct __sk_buff -> struct sk_buff* struct bpf_sock_ops -> struct sock

Proto:static int convert_ctx_accesses(struct bpf_verifier_env *env)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
8748  ops = ops
8749  delta = 0
8750  insn_cnt = Number of filter blocks
8757  If gen_prologue || seen_direct_write Then
8758  If Not gen_prologue Then
8759  verbose(env, "bpf verifier is misconfigured\n")
8760  Return -EINVAL
8762  cnt = gen_prologue(insn_buf, seen_direct_write, BPF program being verified )
8765  verbose(env, "bpf verifier is misconfigured\n")
8766  Return -EINVAL
8767  Else if cnt Then
8769  If Not new_prog Then Return -ENOMEM
8773  delta += cnt - 1
8777  If bpf_prog_is_dev_bound( Auxiliary fields ) Then Return 0
8780  insn = insnsi + delta
8782  When i < insn_cnt cycle
8785  If opcode == ( BPF_LDX | BPF_MEM | 8-bit ) || opcode == ( BPF_LDX | BPF_MEM | 16-bit ) || opcode == ( BPF_LDX | BPF_MEM | 32-bit ) || opcode == ( BPF_LDX | BPF_MEM | double word (64-bit) ) Then type = BPF_READ
8790  Else if opcode == ( BPF_STX | BPF_MEM | 8-bit ) || opcode == ( BPF_STX | BPF_MEM | 16-bit ) || opcode == ( BPF_STX | BPF_MEM | 32-bit ) || opcode == ( BPF_STX | BPF_MEM | double word (64-bit) ) Then type = BPF_WRITE
8795  Else Continue
8817  If Not new_prog Then Return -ENOMEM
8820  delta += cnt - 1
8822  insn = insnsi + i + delta
8823  Continue
8828  If Not convert_ctx_access Then Continue
8831  Break
8843  If type == BPF_WRITE Then
8844  verbose(env, "Writes through BTF pointers are not allowed\n")
8845  Return -EINVAL
8848  num_exentries++
8849  Continue
8850  Default
8851  Continue
8865  If is_narrower_load Then
8868  If type == BPF_WRITE Then
8869  verbose(env, "bpf verifier narrow ctx access misconfigured\n")
8870  Return -EINVAL
8873  size_code = 16-bit
8874  If ctx_field_size == 4 Then size_code = 32-bit
8876  Else if ctx_field_size == 8 Then size_code = double word (64-bit)
8879  signed offset = off & ~(size_default - 1)
8883  target_size = 0
8888  verbose(env, "bpf verifier is misconfigured\n")
8889  Return -EINVAL
8892  If is_narrower_load && size < target_size Then
8913  If Not new_prog Then Return -ENOMEM
8916  delta += cnt - 1
8920  insn = insnsi + i + delta
8923  Return 0
Caller
NameDescribe
bpf_check