root/tools/testing/selftests/bpf/verifier/basic_stack.c

/* [<][>][^][v][top][bottom][index][help] */
   1 {
   2         "stack out of bounds",
   3         .insns = {
   4         BPF_ST_MEM(BPF_DW, BPF_REG_10, 8, 0),
   5         BPF_EXIT_INSN(),
   6         },
   7         .errstr = "invalid stack",
   8         .result = REJECT,
   9 },
  10 {
  11         "uninitialized stack1",
  12         .insns = {
  13         BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
  14         BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
  15         BPF_LD_MAP_FD(BPF_REG_1, 0),
  16         BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem),
  17         BPF_EXIT_INSN(),
  18         },
  19         .fixup_map_hash_8b = { 2 },
  20         .errstr = "invalid indirect read from stack",
  21         .result = REJECT,
  22 },
  23 {
  24         "uninitialized stack2",
  25         .insns = {
  26         BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
  27         BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_2, -8),
  28         BPF_EXIT_INSN(),
  29         },
  30         .errstr = "invalid read from stack",
  31         .result = REJECT,
  32 },
  33 {
  34         "invalid fp arithmetic",
  35         /* If this gets ever changed, make sure JITs can deal with it. */
  36         .insns = {
  37         BPF_MOV64_IMM(BPF_REG_0, 0),
  38         BPF_MOV64_REG(BPF_REG_1, BPF_REG_10),
  39         BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 8),
  40         BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, 0),
  41         BPF_EXIT_INSN(),
  42         },
  43         .errstr = "R1 subtraction from stack pointer",
  44         .result = REJECT,
  45 },
  46 {
  47         "non-invalid fp arithmetic",
  48         .insns = {
  49         BPF_MOV64_IMM(BPF_REG_0, 0),
  50         BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
  51         BPF_EXIT_INSN(),
  52         },
  53         .result = ACCEPT,
  54 },
  55 {
  56         "misaligned read from stack",
  57         .insns = {
  58         BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
  59         BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_2, -4),
  60         BPF_EXIT_INSN(),
  61         },
  62         .errstr = "misaligned stack access",
  63         .result = REJECT,
  64 },

/* [<][>][^][v][top][bottom][index][help] */