* [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector
@ 2024-05-29 23:12 Andrii Nakryiko
2024-05-30 6:19 ` Jiri Olsa
2024-05-31 22:01 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2024-05-29 23:12 UTC (permalink / raw)
To: bpf, ast, daniel, martin.lau; +Cc: andrii, kernel-team
Guard close(link_fd) with extra link_fd >= 0 check to prevent close(-1).
Detected by Coverity static analysis.
Fixes: 04d939a2ab22 ("libbpf: detect broken PID filtering logic for multi-uprobe")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/features.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/features.c b/tools/lib/bpf/features.c
index 3df0125ed5fa..50befe125ddc 100644
--- a/tools/lib/bpf/features.c
+++ b/tools/lib/bpf/features.c
@@ -393,7 +393,8 @@ static int probe_uprobe_multi_link(int token_fd)
err = -errno; /* close() can clobber errno */
if (link_fd >= 0 || err != -EBADF) {
- close(link_fd);
+ if (link_fd >= 0)
+ close(link_fd);
close(prog_fd);
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector
2024-05-29 23:12 [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector Andrii Nakryiko
@ 2024-05-30 6:19 ` Jiri Olsa
2024-05-31 22:01 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2024-05-30 6:19 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, ast, daniel, martin.lau, kernel-team
On Wed, May 29, 2024 at 04:12:12PM -0700, Andrii Nakryiko wrote:
> Guard close(link_fd) with extra link_fd >= 0 check to prevent close(-1).
>
> Detected by Coverity static analysis.
>
> Fixes: 04d939a2ab22 ("libbpf: detect broken PID filtering logic for multi-uprobe")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
jirka
> ---
> tools/lib/bpf/features.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/features.c b/tools/lib/bpf/features.c
> index 3df0125ed5fa..50befe125ddc 100644
> --- a/tools/lib/bpf/features.c
> +++ b/tools/lib/bpf/features.c
> @@ -393,7 +393,8 @@ static int probe_uprobe_multi_link(int token_fd)
> err = -errno; /* close() can clobber errno */
>
> if (link_fd >= 0 || err != -EBADF) {
> - close(link_fd);
> + if (link_fd >= 0)
> + close(link_fd);
> close(prog_fd);
> return 0;
> }
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector
2024-05-29 23:12 [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector Andrii Nakryiko
2024-05-30 6:19 ` Jiri Olsa
@ 2024-05-31 22:01 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-31 22:01 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, ast, daniel, martin.lau, kernel-team
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Wed, 29 May 2024 16:12:12 -0700 you wrote:
> Guard close(link_fd) with extra link_fd >= 0 check to prevent close(-1).
>
> Detected by Coverity static analysis.
>
> Fixes: 04d939a2ab22 ("libbpf: detect broken PID filtering logic for multi-uprobe")
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
>
> [...]
Here is the summary with links:
- [bpf] libbpf: don't close(-1) in multi-uprobe feature detector
https://git.kernel.org/bpf/bpf/c/7d0b3953f6d8
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
end of thread, other threads:[~2024-05-31 22:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 23:12 [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector Andrii Nakryiko
2024-05-30 6:19 ` Jiri Olsa
2024-05-31 22:01 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox