Skip to contentSkip to conversation

selftests/bpf: fix a typo in map in map test

PATCH Applied Roman Gushchin 3 participants 3 messages Aug 2, 2018 – Aug 3, 2018

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: fix a typo in map in map test

Commit fbeb1603bf4e ("bpf: verifier: MOV64 don't mark dst reg unbounded") revealed a typo in commit fb30d4b71214 ("bpf: Add tests for map-in-map"):
BPF_MOV64_REG(BPF_REG_0, 0) was used instead of BPF_MOV64_IMM(BPF_REG_0, 0).

I've noticed the problem by running bpf kselftests.

Fixes fb30d4b71214 ("bpf: Add tests for map-in-map")
Cc Martin KaFai Lau <[email protected]>
Cc Arthur Fabre <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Alexei Starovoitov <[email protected]>
---
 tools/testing/selftests/bpf/test_verifier.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/test_verifier.c +3 -3
index 4b5e03c25204..ac281ee771dd 100644
@@ -7113,7 +7113,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
 			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
 				     BPF_FUNC_map_lookup_elem),
-			BPF_MOV64_REG(BPF_REG_0, 0),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
 		.fixup_map_in_map = { 3 },
@@ -7136,7 +7136,7 @@ static struct bpf_test tests[] = {
 			BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 8),
 			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
 				     BPF_FUNC_map_lookup_elem),
-			BPF_MOV64_REG(BPF_REG_0, 0),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
 		.fixup_map_in_map = { 3 },
@@ -7158,7 +7158,7 @@ static struct bpf_test tests[] = {
 			BPF_MOV64_REG(BPF_REG_1, BPF_REG_0),
 			BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0,
 				     BPF_FUNC_map_lookup_elem),
-			BPF_MOV64_REG(BPF_REG_0, 0),
+			BPF_MOV64_IMM(BPF_REG_0, 0),
 			BPF_EXIT_INSN(),
 		},
 		.fixup_map_in_map = { 3 },
Signature · 1 line
2.14.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Roman Gushchin

Commit fbeb1603bf4e ("bpf: verifier: MOV64 don't mark dst reg unbounded") revealed a typo in commit fb30d4b71214 ("bpf: Add tests for map-in-map"):
BPF_MOV64_REG(BPF_REG_0, 0) was used instead of BPF_MOV64_IMM(BPF_REG_0, 0).

I've noticed the problem by running bpf kselftests.

Thanks for the fix!

FWIW, here is the verifier log:
11: (85) call bpf_map_lookup_elem#1
12: (bf) r0 = r0
13: (95) exit
R0 leaks addr as return value

maintainer Applied
#2 lore raw
In reply to Roman Gushchin
Quoted 5 lines · Roman Gushchin

Commit fbeb1603bf4e ("bpf: verifier: MOV64 don't mark dst reg unbounded") revealed a typo in commit fb30d4b71214 ("bpf: Add tests for map-in-map"):
BPF_MOV64_REG(BPF_REG_0, 0) was used instead of BPF_MOV64_IMM(BPF_REG_0, 0).

Quoted 8 lines

I've noticed the problem by running bpf kselftests.

Fixes fb30d4b71214 ("bpf: Add tests for map-in-map")
Cc Martin KaFai Lau <[email protected]>
Cc Arthur Fabre <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Alexei Starovoitov <[email protected]>

Applied to bpf-next, thanks Roman!