Back to home page

OSCL-LXR

 
 

    


0001 {
0002     "BPF_ATOMIC bounds propagation, mem->reg",
0003     .insns = {
0004         /* a = 0; */
0005         /*
0006          * Note this is implemented with two separate instructions,
0007          * where you might think one would suffice:
0008          *
0009          * BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
0010          *
0011          * This is because BPF_ST_MEM doesn't seem to set the stack slot
0012          * type to 0 when storing an immediate.
0013          */
0014         BPF_MOV64_IMM(BPF_REG_0, 0),
0015         BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
0016         /* b = atomic_fetch_add(&a, 1); */
0017         BPF_MOV64_IMM(BPF_REG_1, 1),
0018         BPF_ATOMIC_OP(BPF_DW, BPF_ADD | BPF_FETCH, BPF_REG_10, BPF_REG_1, -8),
0019         /* Verifier should be able to tell that this infinite loop isn't reachable. */
0020         /* if (b) while (true) continue; */
0021         BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, -1),
0022         BPF_EXIT_INSN(),
0023     },
0024     .result = ACCEPT,
0025     .result_unpriv = REJECT,
0026     .errstr_unpriv = "back-edge",
0027 },