|
@@ -8647,7 +8647,7 @@ static struct bpf_test tests[] = {
|
|
|
offsetof(struct __sk_buff, mark)),
|
|
|
BPF_EXIT_INSN(),
|
|
|
},
|
|
|
- .errstr = "dereference of modified ctx ptr R1 off=68+8, ctx+const is allowed, ctx+const+const is not",
|
|
|
+ .errstr = "dereference of modified ctx ptr",
|
|
|
.result = REJECT,
|
|
|
.prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
},
|
|
@@ -12258,6 +12258,62 @@ static struct bpf_test tests[] = {
|
|
|
.result = ACCEPT,
|
|
|
.retval = 5,
|
|
|
},
|
|
|
+ {
|
|
|
+ "pass unmodified ctx pointer to helper",
|
|
|
+ .insns = {
|
|
|
+ BPF_MOV64_IMM(BPF_REG_2, 0),
|
|
|
+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
|
|
|
+ BPF_FUNC_csum_update),
|
|
|
+ BPF_MOV64_IMM(BPF_REG_0, 0),
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
+ },
|
|
|
+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
+ .result = ACCEPT,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "pass modified ctx pointer to helper, 1",
|
|
|
+ .insns = {
|
|
|
+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -612),
|
|
|
+ BPF_MOV64_IMM(BPF_REG_2, 0),
|
|
|
+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
|
|
|
+ BPF_FUNC_csum_update),
|
|
|
+ BPF_MOV64_IMM(BPF_REG_0, 0),
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
+ },
|
|
|
+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
+ .result = REJECT,
|
|
|
+ .errstr = "dereference of modified ctx ptr",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "pass modified ctx pointer to helper, 2",
|
|
|
+ .insns = {
|
|
|
+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, -612),
|
|
|
+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
|
|
|
+ BPF_FUNC_get_socket_cookie),
|
|
|
+ BPF_MOV64_IMM(BPF_REG_0, 0),
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
+ },
|
|
|
+ .result_unpriv = REJECT,
|
|
|
+ .result = REJECT,
|
|
|
+ .errstr_unpriv = "dereference of modified ctx ptr",
|
|
|
+ .errstr = "dereference of modified ctx ptr",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "pass modified ctx pointer to helper, 3",
|
|
|
+ .insns = {
|
|
|
+ BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, 0),
|
|
|
+ BPF_ALU64_IMM(BPF_AND, BPF_REG_3, 4),
|
|
|
+ BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
|
|
|
+ BPF_MOV64_IMM(BPF_REG_2, 0),
|
|
|
+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
|
|
|
+ BPF_FUNC_csum_update),
|
|
|
+ BPF_MOV64_IMM(BPF_REG_0, 0),
|
|
|
+ BPF_EXIT_INSN(),
|
|
|
+ },
|
|
|
+ .prog_type = BPF_PROG_TYPE_SCHED_CLS,
|
|
|
+ .result = REJECT,
|
|
|
+ .errstr = "variable ctx access var_off=(0x0; 0x4)",
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
static int probe_filter_length(const struct bpf_insn *fp)
|