* [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress()
@ 2024-06-23 13:17 Ma Ke
2024-06-26 23:40 ` patchwork-bot+netdevbpf
2024-06-26 23:41 ` Andrii Nakryiko
0 siblings, 2 replies; 3+ messages in thread
From: Ma Ke @ 2024-06-23 13:17 UTC (permalink / raw)
To: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, shuah,
make24
Cc: bpf, linux-kselftest, linux-kernel
Guard close() with extra link_fd[i] >= 0 and fexit_fd[i] >= 0
check to prevent close(-1).
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
tools/testing/selftests/bpf/prog_tests/fexit_stress.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
index 596536def43d..94ff1d9fc9e4 100644
--- a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
+++ b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
@@ -50,9 +50,9 @@ void serial_test_fexit_stress(void)
out:
for (i = 0; i < bpf_max_tramp_links; i++) {
- if (link_fd[i])
+ if (link_fd[i] >= 0)
close(link_fd[i]);
- if (fexit_fd[i])
+ if (fexit_fd[i] >= 0)
close(fexit_fd[i]);
}
free(fd);
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress()
2024-06-23 13:17 [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress() Ma Ke
@ 2024-06-26 23:40 ` patchwork-bot+netdevbpf
2024-06-26 23:41 ` Andrii Nakryiko
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-06-26 23:40 UTC (permalink / raw)
To: Ma Ke
Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, shuah, bpf,
linux-kselftest, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Sun, 23 Jun 2024 21:17:53 +0800 you wrote:
> Guard close() with extra link_fd[i] >= 0 and fexit_fd[i] >= 0
> check to prevent close(-1).
>
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> tools/testing/selftests/bpf/prog_tests/fexit_stress.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Here is the summary with links:
- selftests/bpf: don't close(-1) in serial_test_fexit_stress()
https://git.kernel.org/bpf/bpf-next/c/d07980f7373b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress()
2024-06-23 13:17 [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress() Ma Ke
2024-06-26 23:40 ` patchwork-bot+netdevbpf
@ 2024-06-26 23:41 ` Andrii Nakryiko
1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2024-06-26 23:41 UTC (permalink / raw)
To: Ma Ke
Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, shuah, bpf,
linux-kselftest, linux-kernel
On Sun, Jun 23, 2024 at 6:18 AM Ma Ke <make24@iscas.ac.cn> wrote:
>
> Guard close() with extra link_fd[i] >= 0 and fexit_fd[i] >= 0
> check to prevent close(-1).
>
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> tools/testing/selftests/bpf/prog_tests/fexit_stress.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
> index 596536def43d..94ff1d9fc9e4 100644
> --- a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
> +++ b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
> @@ -50,9 +50,9 @@ void serial_test_fexit_stress(void)
>
> out:
> for (i = 0; i < bpf_max_tramp_links; i++) {
> - if (link_fd[i])
> + if (link_fd[i] >= 0)
> close(link_fd[i]);
> - if (fexit_fd[i])
> + if (fexit_fd[i] >= 0)
> close(fexit_fd[i]);
bpf_link_create() and bpf_prog_load() will return FDs > 2, so we
should just check > 0 conditions. I fixed it up while applying.
> }
> free(fd);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-26 23:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-23 13:17 [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress() Ma Ke
2024-06-26 23:40 ` patchwork-bot+netdevbpf
2024-06-26 23:41 ` Andrii Nakryiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®