mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 14:43:16 +00:00
bpf: change bpf_probe_write_user to bpf_trace_printk in test_verifier
There are four tests in test_verifier using bpf_probe_write_user helper. These four tests will emit the following kernel messages [ 12.974753] test_verifier[220] is installing a program with bpf_probe_write_user helper that may corrupt user memory! [ 12.979285] test_verifier[220] is installing a program with bpf_probe_write_user helper that may corrupt user memory! ...... This may confuse certain users. This patch replaces bpf_probe_write_user with bpf_trace_printk. The test_verifier already uses bpf_trace_printk earlier in the test and a trace_printk warning message has been printed. So this patch does not emit any more kernel messages. Fixes: b6ff63911232 ("bpf: fix and add test cases for ARG_CONST_SIZE_OR_ZERO semantics change") Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
6547f424be
commit
f1a8b8e3d9
@ -4377,11 +4377,10 @@ static struct bpf_test tests[] = {
|
|||||||
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
||||||
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
||||||
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
||||||
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
|
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 3),
|
||||||
BPF_MOV64_IMM(BPF_REG_1, 0),
|
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
||||||
BPF_MOV64_REG(BPF_REG_2, BPF_REG_0),
|
BPF_MOV64_IMM(BPF_REG_2, 0),
|
||||||
BPF_MOV64_IMM(BPF_REG_3, 0),
|
BPF_EMIT_CALL(BPF_FUNC_trace_printk),
|
||||||
BPF_EMIT_CALL(BPF_FUNC_probe_write_user),
|
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.fixup_map2 = { 3 },
|
.fixup_map2 = { 3 },
|
||||||
@ -4481,14 +4480,12 @@ static struct bpf_test tests[] = {
|
|||||||
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
||||||
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
||||||
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
||||||
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
|
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4),
|
||||||
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
||||||
BPF_ALU64_IMM(BPF_ADD, BPF_REG_1,
|
BPF_ALU64_IMM(BPF_ADD, BPF_REG_1,
|
||||||
offsetof(struct test_val, foo)),
|
offsetof(struct test_val, foo)),
|
||||||
BPF_MOV64_REG(BPF_REG_2, BPF_REG_1),
|
BPF_MOV64_IMM(BPF_REG_2, 0),
|
||||||
BPF_MOV64_IMM(BPF_REG_1, 0),
|
BPF_EMIT_CALL(BPF_FUNC_trace_printk),
|
||||||
BPF_MOV64_IMM(BPF_REG_3, 0),
|
|
||||||
BPF_EMIT_CALL(BPF_FUNC_probe_write_user),
|
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.fixup_map2 = { 3 },
|
.fixup_map2 = { 3 },
|
||||||
@ -4618,18 +4615,16 @@ static struct bpf_test tests[] = {
|
|||||||
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
||||||
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
||||||
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
||||||
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
|
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 5),
|
||||||
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
||||||
BPF_MOV64_IMM(BPF_REG_3, 0),
|
BPF_MOV64_IMM(BPF_REG_3, 0),
|
||||||
BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
|
BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
|
||||||
BPF_MOV64_REG(BPF_REG_2, BPF_REG_1),
|
BPF_MOV64_IMM(BPF_REG_2, 0),
|
||||||
BPF_MOV64_IMM(BPF_REG_1, 0),
|
BPF_EMIT_CALL(BPF_FUNC_trace_printk),
|
||||||
BPF_MOV64_IMM(BPF_REG_3, 0),
|
|
||||||
BPF_EMIT_CALL(BPF_FUNC_probe_write_user),
|
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.fixup_map2 = { 3 },
|
.fixup_map2 = { 3 },
|
||||||
.errstr = "R2 min value is outside of the array range",
|
.errstr = "R1 min value is outside of the array range",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
.prog_type = BPF_PROG_TYPE_TRACEPOINT,
|
.prog_type = BPF_PROG_TYPE_TRACEPOINT,
|
||||||
},
|
},
|
||||||
@ -4760,20 +4755,18 @@ static struct bpf_test tests[] = {
|
|||||||
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
|
||||||
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
BPF_LD_MAP_FD(BPF_REG_1, 0),
|
||||||
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
|
||||||
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7),
|
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
|
||||||
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
|
||||||
BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
|
BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_0, 0),
|
||||||
BPF_JMP_IMM(BPF_JGT, BPF_REG_3,
|
BPF_JMP_IMM(BPF_JGT, BPF_REG_3,
|
||||||
offsetof(struct test_val, foo), 4),
|
offsetof(struct test_val, foo), 3),
|
||||||
BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
|
BPF_ALU64_REG(BPF_ADD, BPF_REG_1, BPF_REG_3),
|
||||||
BPF_MOV64_REG(BPF_REG_2, BPF_REG_1),
|
BPF_MOV64_IMM(BPF_REG_2, 0),
|
||||||
BPF_MOV64_IMM(BPF_REG_1, 0),
|
BPF_EMIT_CALL(BPF_FUNC_trace_printk),
|
||||||
BPF_MOV64_IMM(BPF_REG_3, 0),
|
|
||||||
BPF_EMIT_CALL(BPF_FUNC_probe_write_user),
|
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
},
|
},
|
||||||
.fixup_map2 = { 3 },
|
.fixup_map2 = { 3 },
|
||||||
.errstr = "R2 min value is outside of the array range",
|
.errstr = "R1 min value is outside of the array range",
|
||||||
.result = REJECT,
|
.result = REJECT,
|
||||||
.prog_type = BPF_PROG_TYPE_TRACEPOINT,
|
.prog_type = BPF_PROG_TYPE_TRACEPOINT,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user