Message ID | 20230903151448.61696-4-hffilwlqm@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf, x64: Fix tailcall infinite loop | expand |
On Sun, Sep 03, 2023 at 11:14:47PM +0800, Leon Hwang wrote: > Get and check data_fd. It should not to check map_fd again. > > Fixes: 79d49ba048ec ("bpf, testing: Add various tail call test cases") > Fixes: 3b0379111197 ("selftests/bpf: Add tailcall_bpf2bpf tests") > Fixes: 5e0b0a4c52d3 ("selftests/bpf: Test tail call counting with bpf2bpf and data on stack") > Signed-off-by: Leon Hwang <hffilwlqm@gmail.com> This could be pulled out of this RFC set and sent separately to bpf tree, given that Ilya is taking a look at addressing s390 jit. > --- > tools/testing/selftests/bpf/prog_tests/tailcalls.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/tools/testing/selftests/bpf/prog_tests/tailcalls.c b/tools/testing/selftests/bpf/prog_tests/tailcalls.c > index 58fe2c586ed76..b20d7f77a5bce 100644 > --- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c > +++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c > @@ -274,7 +274,7 @@ static void test_tailcall_count(const char *which) > return; > > data_fd = bpf_map__fd(data_map); > - if (CHECK_FAIL(map_fd < 0)) > + if (CHECK_FAIL(data_fd < 0)) > return; > > i = 0; > @@ -355,7 +355,7 @@ static void test_tailcall_4(void) > return; > > data_fd = bpf_map__fd(data_map); > - if (CHECK_FAIL(map_fd < 0)) > + if (CHECK_FAIL(data_fd < 0)) > return; > > for (i = 0; i < bpf_map__max_entries(prog_array); i++) { > @@ -445,7 +445,7 @@ static void test_tailcall_5(void) > return; > > data_fd = bpf_map__fd(data_map); > - if (CHECK_FAIL(map_fd < 0)) > + if (CHECK_FAIL(data_fd < 0)) > return; shouldn't this be 'goto out' ? applies to the rest of the code i believe. > > for (i = 0; i < bpf_map__max_entries(prog_array); i++) { > @@ -634,7 +634,7 @@ static void test_tailcall_bpf2bpf_2(void) > return; > > data_fd = bpf_map__fd(data_map); > - if (CHECK_FAIL(map_fd < 0)) > + if (CHECK_FAIL(data_fd < 0)) > return; > > i = 0; > @@ -808,7 +808,7 @@ static void test_tailcall_bpf2bpf_4(bool noise) > return; > > data_fd = bpf_map__fd(data_map); > - if (CHECK_FAIL(map_fd < 0)) > + if (CHECK_FAIL(data_fd < 0)) > return; > > i = 0; > @@ -872,7 +872,7 @@ static void test_tailcall_bpf2bpf_6(void) > ASSERT_EQ(topts.retval, 0, "tailcall retval"); > > data_fd = bpf_map__fd(obj->maps.bss); > - if (!ASSERT_GE(map_fd, 0, "bss map fd")) > + if (!ASSERT_GE(data_fd, 0, "bss map fd")) > goto out; > > i = 0; > -- > 2.41.0 >
On 6/9/23 03:22, Maciej Fijalkowski wrote: > On Sun, Sep 03, 2023 at 11:14:47PM +0800, Leon Hwang wrote: >> Get and check data_fd. It should not to check map_fd again. >> >> Fixes: 79d49ba048ec ("bpf, testing: Add various tail call test cases") >> Fixes: 3b0379111197 ("selftests/bpf: Add tailcall_bpf2bpf tests") >> Fixes: 5e0b0a4c52d3 ("selftests/bpf: Test tail call counting with bpf2bpf and data on stack") >> Signed-off-by: Leon Hwang <hffilwlqm@gmail.com> > > This could be pulled out of this RFC set and sent separately to bpf tree, > given that Ilya is taking a look at addressing s390 jit. Yeah, I'll do it. > >> --- >> tools/testing/selftests/bpf/prog_tests/tailcalls.c | 12 ++++++------ >> 1 file changed, 6 insertions(+), 6 deletions(-) >> >> diff --git a/tools/testing/selftests/bpf/prog_tests/tailcalls.c b/tools/testing/selftests/bpf/prog_tests/tailcalls.c >> index 58fe2c586ed76..b20d7f77a5bce 100644 >> --- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c >> +++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c >> @@ -274,7 +274,7 @@ static void test_tailcall_count(const char *which) >> return; >> >> data_fd = bpf_map__fd(data_map); >> - if (CHECK_FAIL(map_fd < 0)) >> + if (CHECK_FAIL(data_fd < 0)) >> return; >> >> i = 0; >> @@ -355,7 +355,7 @@ static void test_tailcall_4(void) >> return; >> >> data_fd = bpf_map__fd(data_map); >> - if (CHECK_FAIL(map_fd < 0)) >> + if (CHECK_FAIL(data_fd < 0)) >> return; >> >> for (i = 0; i < bpf_map__max_entries(prog_array); i++) { >> @@ -445,7 +445,7 @@ static void test_tailcall_5(void) >> return; >> >> data_fd = bpf_map__fd(data_map); >> - if (CHECK_FAIL(map_fd < 0)) >> + if (CHECK_FAIL(data_fd < 0)) >> return; > > shouldn't this be 'goto out' ? applies to the rest of the code i believe. Good point. I'll correct some other 'return' to 'goto out' meanwhile. Thanks, Leon > >> >> for (i = 0; i < bpf_map__max_entries(prog_array); i++) { >> @@ -634,7 +634,7 @@ static void test_tailcall_bpf2bpf_2(void) >> return; >> >> data_fd = bpf_map__fd(data_map); >> - if (CHECK_FAIL(map_fd < 0)) >> + if (CHECK_FAIL(data_fd < 0)) >> return; >> >> i = 0; >> @@ -808,7 +808,7 @@ static void test_tailcall_bpf2bpf_4(bool noise) >> return; >> >> data_fd = bpf_map__fd(data_map); >> - if (CHECK_FAIL(map_fd < 0)) >> + if (CHECK_FAIL(data_fd < 0)) >> return; >> >> i = 0; >> @@ -872,7 +872,7 @@ static void test_tailcall_bpf2bpf_6(void) >> ASSERT_EQ(topts.retval, 0, "tailcall retval"); >> >> data_fd = bpf_map__fd(obj->maps.bss); >> - if (!ASSERT_GE(map_fd, 0, "bss map fd")) >> + if (!ASSERT_GE(data_fd, 0, "bss map fd")) >> goto out; >> >> i = 0; >> -- >> 2.41.0 >>
diff --git a/tools/testing/selftests/bpf/prog_tests/tailcalls.c b/tools/testing/selftests/bpf/prog_tests/tailcalls.c index 58fe2c586ed76..b20d7f77a5bce 100644 --- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c +++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c @@ -274,7 +274,7 @@ static void test_tailcall_count(const char *which) return; data_fd = bpf_map__fd(data_map); - if (CHECK_FAIL(map_fd < 0)) + if (CHECK_FAIL(data_fd < 0)) return; i = 0; @@ -355,7 +355,7 @@ static void test_tailcall_4(void) return; data_fd = bpf_map__fd(data_map); - if (CHECK_FAIL(map_fd < 0)) + if (CHECK_FAIL(data_fd < 0)) return; for (i = 0; i < bpf_map__max_entries(prog_array); i++) { @@ -445,7 +445,7 @@ static void test_tailcall_5(void) return; data_fd = bpf_map__fd(data_map); - if (CHECK_FAIL(map_fd < 0)) + if (CHECK_FAIL(data_fd < 0)) return; for (i = 0; i < bpf_map__max_entries(prog_array); i++) { @@ -634,7 +634,7 @@ static void test_tailcall_bpf2bpf_2(void) return; data_fd = bpf_map__fd(data_map); - if (CHECK_FAIL(map_fd < 0)) + if (CHECK_FAIL(data_fd < 0)) return; i = 0; @@ -808,7 +808,7 @@ static void test_tailcall_bpf2bpf_4(bool noise) return; data_fd = bpf_map__fd(data_map); - if (CHECK_FAIL(map_fd < 0)) + if (CHECK_FAIL(data_fd < 0)) return; i = 0; @@ -872,7 +872,7 @@ static void test_tailcall_bpf2bpf_6(void) ASSERT_EQ(topts.retval, 0, "tailcall retval"); data_fd = bpf_map__fd(obj->maps.bss); - if (!ASSERT_GE(map_fd, 0, "bss map fd")) + if (!ASSERT_GE(data_fd, 0, "bss map fd")) goto out; i = 0;
Get and check data_fd. It should not to check map_fd again. Fixes: 79d49ba048ec ("bpf, testing: Add various tail call test cases") Fixes: 3b0379111197 ("selftests/bpf: Add tailcall_bpf2bpf tests") Fixes: 5e0b0a4c52d3 ("selftests/bpf: Test tail call counting with bpf2bpf and data on stack") Signed-off-by: Leon Hwang <hffilwlqm@gmail.com> --- tools/testing/selftests/bpf/prog_tests/tailcalls.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)