* [PATCH bpf-next 2/2] selftests/bpf: check null propagation only neither reg is PTR_TO_BTF_ID
@ 2022-12-12 4:15 Hao Sun
2022-12-12 23:22 ` Yonghong Song
0 siblings, 1 reply; 2+ messages in thread
From: Hao Sun @ 2022-12-12 4:15 UTC (permalink / raw)
To: bpf
Cc: ast, daniel, john.fastabend, andrii, martin.lau, song, yhs,
kpsingh, sdf, haoluo, jolsa, davem, linux-kernel, Hao Sun
Verify that nullness information is not porpagated in the branches
of register to register JEQ and JNE operations if one of them is
PTR_TO_BTF_ID.
Signed-off-by: Hao Sun <sunhao.th@gmail.com>
---
.../bpf/verifier/jeq_infer_not_null.c | 22 +++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/tools/testing/selftests/bpf/verifier/jeq_infer_not_null.c b/tools/testing/selftests/bpf/verifier/jeq_infer_not_null.c
index 67a1c07ead34..b2b215227d97 100644
--- a/tools/testing/selftests/bpf/verifier/jeq_infer_not_null.c
+++ b/tools/testing/selftests/bpf/verifier/jeq_infer_not_null.c
@@ -172,3 +172,25 @@
.prog_type = BPF_PROG_TYPE_XDP,
.result = ACCEPT,
},
+{
+ "jne/jeq infer not null, PTR_TO_MAP_OR_NULL unchanged with PTR_TO_BTF_ID reg",
+ .insns = {
+ BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+ BPF_ST_MEM(BPF_DW, BPF_REG_2, 0, 0),
+ BPF_LD_MAP_FD(BPF_REG_1, 0),
+ /* r6 = bpf_map->inner_map_meta; */
+ BPF_LDX_MEM(BPF_DW, BPF_REG_6, BPF_REG_1, 8),
+ /* r0 = map_lookup_elem(r1, r2); */
+ BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
+ /* if (r0 == r6) read *r0; */
+ BPF_JMP_REG(BPF_JEQ, BPF_REG_6, BPF_REG_0, 1),
+ BPF_EXIT_INSN(),
+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 0),
+ BPF_EXIT_INSN(),
+ },
+ .fixup_map_hash_8b = { 3 },
+ .prog_type = BPF_PROG_TYPE_XDP,
+ .result = REJECT,
+ .errstr = "R0 invalid mem access 'map_value_or_null'",
+},
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next 2/2] selftests/bpf: check null propagation only neither reg is PTR_TO_BTF_ID
2022-12-12 4:15 [PATCH bpf-next 2/2] selftests/bpf: check null propagation only neither reg is PTR_TO_BTF_ID Hao Sun
@ 2022-12-12 23:22 ` Yonghong Song
0 siblings, 0 replies; 2+ messages in thread
From: Yonghong Song @ 2022-12-12 23:22 UTC (permalink / raw)
To: Hao Sun, bpf
Cc: ast, daniel, john.fastabend, andrii, martin.lau, song, yhs,
kpsingh, sdf, haoluo, jolsa, davem, linux-kernel
On 12/11/22 8:15 PM, Hao Sun wrote:
> Verify that nullness information is not porpagated in the branches
> of register to register JEQ and JNE operations if one of them is
> PTR_TO_BTF_ID.
>
> Signed-off-by: Hao Sun <sunhao.th@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-12 23:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-12 4:15 [PATCH bpf-next 2/2] selftests/bpf: check null propagation only neither reg is PTR_TO_BTF_ID Hao Sun
2022-12-12 23:22 ` Yonghong Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox