Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:verify safety of LD_ABS|LD_IND instructions:* - they can only appear in the programs where ctx == skb* - since they are wrappers of function calls, they scratch R1-R5 registers,* preserve R6-R9, and store return value into R0* Implicit input:* ctx == skb

Proto:static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
struct bpf_insn *insn
6273  regs = cur_regs(env)
6274  ctx_reg = BPF_REG_6
6275  mode = BPF BPF_DW 0x18 64-bit ( opcode )
6278  If Not may_access_skb( Type of BPF program ) Then
6279  verbose(env, "BPF_LD_[ABS|IND] instructions not allowed for this program type\n")
6280  Return -EINVAL
6283  If Not gen_ld_abs Then
6284  verbose(env, "bpf verifier is misconfigured\n")
6285  Return -EINVAL
6288  If subprog_cnt > 1 Then
6296  verbose(env, "BPF_LD_[ABS|IND] instructions cannot be mixed with bpf-to-bpf calls\n")
6297  Return -EINVAL
6300  If dest register != BPF_REG_0 || signed offset != 0 || ld/ldx fields ( opcode ) == double word (64-bit) || mode == BPF_ABS && source register != BPF_REG_0 Then
6303  verbose(env, "BPF_LD_[ABS|IND] uses reserved fields\n")
6304  Return -EINVAL
6308  err = check_reg_arg(env, ctx_reg, register is used as source operand )
6309  If err Then Return err
6316  err = check_reference_leak(env)
6317  If err Then
6318  verbose(env, "BPF_LD_[ABS|IND] cannot be mixed with socket references\n")
6319  Return err
6322  If active_spin_lock Then
6323  verbose(env, "BPF_LD_[ABS|IND] cannot be used inside bpf_spin_lock-ed region\n")
6324  Return -EINVAL
6327  If Ordering of fields matters. See states_equal() != g points to bpf_context Then
6328  verbose(env, "at the time of BPF_LD_ABS|IND R6 != pointer to skb\n")
6330  Return -EINVAL
6333  If mode == BPF_IND Then
6335  err = check_reg_arg(env, source register , register is used as source operand )
6336  If err Then Return err
6340  err = check_ctx_reg(env, & regs[ctx_reg], ctx_reg)
6341  If err < 0 Then Return err
6345  When i < CALLER_SAVED_REGS cycle
6346  mark_reg_not_init(env, regs, caller_saved[i])
6347  check_reg_arg(env, caller_saved[i], DST_OP_NO_MARK)
6354  mark_reg_unknown(env, regs, BPF_REG_0)
6356  Tracks subreg definition. The stored value is the insn_idx of the * writing insn. This is safe because subreg_def is used before any insn * patching which only happens after main verification finished. = insn_idx + 1
6357  Return 0
Caller
NameDescribe
do_check