|
58 | 58 | .result = ACCEPT, |
59 | 59 | .result_unpriv = ACCEPT, |
60 | 60 | }, |
| 61 | +{ |
| 62 | + "check with invalid reg offset 0", |
| 63 | + .insns = { |
| 64 | + /* reserve 8 byte ringbuf memory */ |
| 65 | + BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), |
| 66 | + BPF_LD_MAP_FD(BPF_REG_1, 0), |
| 67 | + BPF_MOV64_IMM(BPF_REG_2, 8), |
| 68 | + BPF_MOV64_IMM(BPF_REG_3, 0), |
| 69 | + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_ringbuf_reserve), |
| 70 | + /* store a pointer to the reserved memory in R6 */ |
| 71 | + BPF_MOV64_REG(BPF_REG_6, BPF_REG_0), |
| 72 | + /* add invalid offset to memory or NULL */ |
| 73 | + BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 1), |
| 74 | + /* check whether the reservation was successful */ |
| 75 | + BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4), |
| 76 | + /* should not be able to access *(R7) = 0 */ |
| 77 | + BPF_ST_MEM(BPF_W, BPF_REG_6, 0, 0), |
| 78 | + /* submit the reserved ringbuf memory */ |
| 79 | + BPF_MOV64_REG(BPF_REG_1, BPF_REG_6), |
| 80 | + BPF_MOV64_IMM(BPF_REG_2, 0), |
| 81 | + BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_ringbuf_submit), |
| 82 | + BPF_MOV64_IMM(BPF_REG_0, 0), |
| 83 | + BPF_EXIT_INSN(), |
| 84 | + }, |
| 85 | + .fixup_map_ringbuf = { 1 }, |
| 86 | + .result = REJECT, |
| 87 | + .errstr = "R0 pointer arithmetic on mem_or_null prohibited", |
| 88 | +}, |
61 | 89 | { |
62 | 90 | "check corrupted spill/fill", |
63 | 91 | .insns = { |
|
0 commit comments