2 "context stores via ST",
4 BPF_MOV64_IMM(BPF_REG_0
, 0),
5 BPF_ST_MEM(BPF_DW
, BPF_REG_1
, offsetof(struct __sk_buff
, mark
), 0),
8 .errstr
= "BPF_ST stores into R1 ctx is not allowed",
10 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
13 "context stores via XADD",
15 BPF_MOV64_IMM(BPF_REG_0
, 0),
16 BPF_RAW_INSN(BPF_STX
| BPF_XADD
| BPF_W
, BPF_REG_1
,
17 BPF_REG_0
, offsetof(struct __sk_buff
, mark
), 0),
20 .errstr
= "BPF_XADD stores into R1 ctx is not allowed",
22 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
25 "arithmetic ops make PTR_TO_CTX unusable",
27 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
,
28 offsetof(struct __sk_buff
, data
) -
29 offsetof(struct __sk_buff
, mark
)),
30 BPF_LDX_MEM(BPF_W
, BPF_REG_0
, BPF_REG_1
,
31 offsetof(struct __sk_buff
, mark
)),
34 .errstr
= "dereference of modified ctx ptr",
36 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
39 "pass unmodified ctx pointer to helper",
41 BPF_MOV64_IMM(BPF_REG_2
, 0),
42 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0,
43 BPF_FUNC_csum_update
),
44 BPF_MOV64_IMM(BPF_REG_0
, 0),
47 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
51 "pass modified ctx pointer to helper, 1",
53 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -612),
54 BPF_MOV64_IMM(BPF_REG_2
, 0),
55 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0,
56 BPF_FUNC_csum_update
),
57 BPF_MOV64_IMM(BPF_REG_0
, 0),
60 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
62 .errstr
= "dereference of modified ctx ptr",
65 "pass modified ctx pointer to helper, 2",
67 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_1
, -612),
68 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0,
69 BPF_FUNC_get_socket_cookie
),
70 BPF_MOV64_IMM(BPF_REG_0
, 0),
73 .result_unpriv
= REJECT
,
75 .errstr_unpriv
= "dereference of modified ctx ptr",
76 .errstr
= "dereference of modified ctx ptr",
79 "pass modified ctx pointer to helper, 3",
81 BPF_LDX_MEM(BPF_W
, BPF_REG_3
, BPF_REG_1
, 0),
82 BPF_ALU64_IMM(BPF_AND
, BPF_REG_3
, 4),
83 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_3
),
84 BPF_MOV64_IMM(BPF_REG_2
, 0),
85 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0,
86 BPF_FUNC_csum_update
),
87 BPF_MOV64_IMM(BPF_REG_0
, 0),
90 .prog_type
= BPF_PROG_TYPE_SCHED_CLS
,
92 .errstr
= "variable ctx access var_off=(0x0; 0x4)",