From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
martin.lau@kernel.org, kernel-team@meta.com
Subject: Re: [PATCH bpf] libbpf: don't close(-1) in multi-uprobe feature detector
Date: Thu, 30 May 2024 08:19:45 +0200 [thread overview]
Message-ID: <ZlgagR3lXeropyXX@krava> (raw)
In-Reply-To: <20240529231212.768828-1-andrii@kernel.org>
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
>
>
next prev parent reply other threads:[~2024-05-30 6:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2024-05-31 22:01 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZlgagR3lXeropyXX@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox