Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:heck validity of 32-bit and 64-bit arithmetic operations

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

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
struct bpf_insn *insn
5166  regs = cur_regs(env)
5167  opcode = alu/jmp fields ( opcode )
5170  If opcode == lags for endianness conversion: || opcode == BPF_NEG Then
5171  If opcode == BPF_NEG Then
5175  verbose(env, "BPF_NEG uses reserved fields\n")
5176  Return -EINVAL
5178  Else
5182  verbose(env, "BPF_END uses reserved fields\n")
5183  Return -EINVAL
5188  err = check_reg_arg(env, dest register , register is used as source operand )
5189  If err Then Return err
5193  verbose(env, "R%d pointer arithmetic prohibited\n", dest register )
5195  Return -EACCES
5199  err = check_reg_arg(env, dest register , register is used as destination operand )
5200  If err Then Return err
5203  Else if opcode == mov reg to reg Then
5205  If BPF_SRC( opcode ) == BPF_X Then
5207  verbose(env, "BPF_MOV uses reserved fields\n")
5208  Return -EINVAL
5213  If err Then Return err
5215  Else
5217  verbose(env, "BPF_MOV uses reserved fields\n")
5218  Return -EINVAL
5223  err = check_reg_arg(env, dest register , DST_OP_NO_MARK)
5224  If err Then Return err
5227  If BPF_SRC( opcode ) == BPF_X Then
5238  Else
5255  Else
5265  Else
5271  Else if opcode > lags for endianness conversion: Then
5272  verbose(env, "invalid BPF_ALU opcode %x\n", opcode)
5273  Return -EINVAL
5275  Else
5277  If BPF_SRC( opcode ) == BPF_X Then
5279  verbose(env, "BPF_ALU uses reserved fields\n")
5280  Return -EINVAL
5284  If err Then Return err
5286  Else
5288  verbose(env, "BPF_ALU uses reserved fields\n")
5289  Return -EINVAL
5294  err = check_reg_arg(env, dest register , register is used as source operand )
5295  If err Then Return err
5298  If ( opcode == BPF_MOD || opcode == BPF_DIV ) && BPF_SRC( opcode ) == BPF_K && signed immediate constant == 0 Then
5300  verbose(env, "div by zero\n")
5301  Return -EINVAL
5309  verbose(env, "invalid shift %d\n", signed immediate constant )
5310  Return -EINVAL
5315  err = check_reg_arg(env, dest register , DST_OP_NO_MARK)
5316  If err Then Return err
5319  Return Handles ALU ops other than BPF_END, BPF_NEG and BPF_MOV: computes new min/max* and var_off.
5322  Return 0
Caller
NameDescribe
do_check