cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

atomic_bounds.c (840B)


      1{
      2	"BPF_ATOMIC bounds propagation, mem->reg",
      3	.insns = {
      4		/* a = 0; */
      5		/*
      6		 * Note this is implemented with two separate instructions,
      7		 * where you might think one would suffice:
      8		 *
      9		 * BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
     10		 *
     11		 * This is because BPF_ST_MEM doesn't seem to set the stack slot
     12		 * type to 0 when storing an immediate.
     13		 */
     14		BPF_MOV64_IMM(BPF_REG_0, 0),
     15		BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, -8),
     16		/* b = atomic_fetch_add(&a, 1); */
     17		BPF_MOV64_IMM(BPF_REG_1, 1),
     18		BPF_ATOMIC_OP(BPF_DW, BPF_ADD | BPF_FETCH, BPF_REG_10, BPF_REG_1, -8),
     19		/* Verifier should be able to tell that this infinite loop isn't reachable. */
     20		/* if (b) while (true) continue; */
     21		BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, -1),
     22		BPF_EXIT_INSN(),
     23	},
     24	.result = ACCEPT,
     25	.result_unpriv = REJECT,
     26	.errstr_unpriv = "back-edge",
     27},