From: Jiri Olsa <olsajiri@gmail.com>
To: Chuang Wang <nashuiliang@gmail.com>
Cc: stable@vger.kernel.org, Song Liu <song@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bpf: Clean up all resources when register_fprobe_ips returns an error
Date: Tue, 25 Oct 2022 11:01:05 +0200 [thread overview]
Message-ID: <Y1el0SXrk8paN1Zm@krava> (raw)
In-Reply-To: <20221025080628.523300-1-nashuiliang@gmail.com>
On Tue, Oct 25, 2022 at 04:06:28PM +0800, Chuang Wang wrote:
> When register_fprobe_ips returns an error, bpf_link_cleanup just cleans
> up bpf_link_primer's resources and forgets to clean up
> bpf_kprobe_multi_link, addrs, cookies.
>
> So, by adding 'goto error', this ensures that all resources are cleaned
> up.
>
> Cc: stable@vger.kernel.org
> Fixes: 0dcac2725406 ("bpf: Add multi kprobe link")
> Signed-off-by: Chuang Wang <nashuiliang@gmail.com>
> ---
> kernel/trace/bpf_trace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 1ed08967fb97..5b806ef20857 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -2778,7 +2778,7 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
> err = register_fprobe_ips(&link->fp, addrs, cnt);
> if (err) {
> bpf_link_cleanup(&link_primer);
> - return err;
> + goto error;
that should be taken care of bpf_kprobe_multi_link_dealloc,
through the fput path in bpf_link_cleanup
do you see any related memory leak like report in kmemleak?
jirka
> }
>
> return bpf_link_settle(&link_primer);
> --
> 2.34.1
>
next prev parent reply other threads:[~2022-10-25 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 8:06 [PATCH] bpf: Clean up all resources when register_fprobe_ips returns an error Chuang Wang
2022-10-25 9:01 ` Jiri Olsa [this message]
2022-10-25 9:36 ` Chuang W
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=Y1el0SXrk8paN1Zm@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mhiramat@kernel.org \
--cc=nashuiliang@gmail.com \
--cc=rostedt@goodmis.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yhs@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).