Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:__mark_chain_precision

Proto:static int __mark_chain_precision(struct bpf_verifier_env *env, int regno, int spi)

Type:int

Parameter:

TypeParameterName
struct bpf_verifier_env *env
intregno
intspi
1730  st = current verifier state
1731  first_idx = first and last insn idx of this verifier state
1732  last_idx = insn_idx
1735  reg_mask = If regno >= 0 Then 1u << regno Else 0
1736  stack_mask = If spi >= 0 Then 1ull << spi Else 0
1737  bool skip_first = true
1738  bool new_marks = false
1741  If Not allow_ptr_leaks Then Return 0
1745  func = call stack tracking [curframe]
1746  If regno >= 0 Then
1747  reg = regs[regno]
1749  WARN_ONCE(1, "backtracing misuse")
1750  Return -EFAULT
1752  If Not if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety Then new_marks = true
1754  Else reg_mask = 0
1756  if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety = true
1759  When spi >= 0 cycle
1761  stack_mask = 0
1762  Break
1764  reg = spilled_ptr
1766  stack_mask = 0
1767  Break
1769  If Not if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety Then new_marks = true
1771  Else stack_mask = 0
1773  if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety = true
1774  Break
1777  If Not new_marks Then Return 0
1779  If Not reg_mask && Not stack_mask Then Return 0
1781  cycle
1782  DECLARE_BITMAP(mask, 64)
1783  history = jmp_history_cnt
1785  If level & BPF_LOG_LEVEL Then verbose(env, "last_idx %d first_idx %d\n", last_idx, first_idx)
1787  cycle
1788  If skip_first Then
1789  err = 0
1790  skip_first = false
1791  Else
1794  If err == -Operation is not supported Then
1797  Else if err Then
1798  Return err
1800  If Not reg_mask && Not stack_mask Then Return 0
1806  If i == first_idx Then Break
1809  If i >= Number of filter blocks Then
1816  verbose(env, "BUG backtracking idx %d\n", i)
1817  WARN_ONCE(1, "verifier backtracking bug")
1818  Return -EFAULT
1821  st = parent
1822  If Not st Then Break
1825  new_marks = false
1826  func = call stack tracking [curframe]
1827  map_from_u64 - Check and swap words within u64.*@mask: source bitmap*@dst: destination bitmap* In 32-bit Big Endian kernel, when using ``(u32 *)(&val)[*]``* to read u64 mask, we will get the wrong word.* That is ``(u32 *)(&val)[0]`` gets the upper 32 bits,
1829  reg = regs[i]
1831  reg_mask &= ~(1u << i)
1832  Continue
1834  If Not if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety Then new_marks = true
1836  if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety = true
1839  map_from_u64 - Check and swap words within u64.*@mask: source bitmap*@dst: destination bitmap* In 32-bit Big Endian kernel, when using ``(u32 *)(&val)[*]``* to read u64 mask, we will get the wrong word.* That is ``(u32 *)(&val)[0]`` gets the upper 32 bits,
1841  If i >= allocated_stack / size of eBPF register in bytes Then
1855  he scalar precision tracking algorithm:* . at the start all registers have precise=false.* . scalar ranges are tracked as normal through alu and jmp insns.* . once precise value of the scalar register is used in:* . ptr + scalar alu*
1856  Return 0
1859  If slot_type[0] != register spilled into stack Then
1860  stack_mask &= ~(1ull << i)
1861  Continue
1863  reg = spilled_ptr
1864  If Ordering of fields matters. See states_equal() != g doesn't contain a valid pointer Then
1865  stack_mask &= ~(1ull << i)
1866  Continue
1868  If Not if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety Then new_marks = true
1870  if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety = true
1872  If level & BPF_LOG_LEVEL Then
1873  print_verifier_state(env, func)
1874  verbose(env, "parent %s regs=%x stack=%llx marks\n", new_marks ? "didn't have" : "already had", reg_mask, stack_mask)
1879  If Not reg_mask && Not stack_mask Then Break
1881  If Not new_marks Then Break
1884  last_idx = last_insn_idx
1885  first_idx = first and last insn idx of this verifier state
1887  Return 0
Caller
NameDescribe
mark_chain_precision
mark_chain_precision_stack