libbpf: don't close(-1) in multi-uprobe feature detector
Andrii Nakryiko
maintainerPATCH 1/1 libbpf: don't close(-1) in multi-uprobe feature detector
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 <[email protected]>
--- tools/lib/bpf/features.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/features.c +2 -1
@@ -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 ; }
Signature · 1 line
2.43.0
Quoted 6 lines · Andrii Nakryiko
Guard
close(link_fd)with extralink_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 <[email protected]>
Acked-by Jiri Olsa <[email protected]>
jirka
Quoted 22 lines
--- tools/lib/bpf/features.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)tools/lib/bpf/features.c +2
-1@@ -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 ; }Signature · 1 line
2.43.0
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:
Quoted 8 lines · On Wed, 29 May 2024 16:12:12 -0700 you wrote:
Guard
close(link_fd)with extralink_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 <[email protected]>[...]
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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html