From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>,
bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Christoph Hellwig <hch@lst.de>,
Masami Hiramatsu <mhiramat@kernel.org>,
Martynas Pumputis <m@lambda.lt>
Subject: Re: [PATCHv2 bpf-next 4/8] bpf: Take module reference on kprobe_multi link
Date: Mon, 24 Oct 2022 10:16:00 +0200 [thread overview]
Message-ID: <Y1ZJwOR0rLIkGzVa@krava> (raw)
In-Reply-To: <CAEf4Bza1p-HZtng4AdAPiV5jbBEstKckWbtAj2aJd2fNqoziZQ@mail.gmail.com>
On Fri, Oct 21, 2022 at 03:02:30PM -0700, Andrii Nakryiko wrote:
SNIP
> > + if (err) {
> > + kprobe_multi_put_modules(args.mods, args.mods_cnt);
> > + kfree(args.mods);
> > + return err;
> > + }
> > +
> > + /* or number of modules found if everything is ok. */
> > + *mods = args.mods;
> > + return args.mods_cnt;
> > +}
> > +
> > int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
> > {
> > struct bpf_kprobe_multi_link *link = NULL;
> > @@ -2773,10 +2850,25 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
> > bpf_kprobe_multi_cookie_cmp,
> > bpf_kprobe_multi_cookie_swap,
> > link);
> > + } else {
> > + /*
> > + * We need to sort addrs array even if there are no cookies
> > + * provided, to allow bsearch in get_modules_for_addrs.
> > + */
> > + sort(addrs, cnt, sizeof(*addrs),
> > + bpf_kprobe_multi_addrs_cmp, NULL);
> > + }
> > +
> > + err = get_modules_for_addrs(&link->mods, addrs, cnt);
> > + if (err < 0) {
> > + bpf_link_cleanup(&link_primer);
> > + return err;
> > }
> > + link->mods_cnt = err;
> >
> > err = register_fprobe_ips(&link->fp, addrs, cnt);
> > if (err) {
> > + kprobe_multi_put_modules(link->mods, link->mods_cnt);
>
> I don't think bpf_link_cleanup() will free link->mods, you have to do
> it explicitly here
hum, so bpf_link_cleanup sets link->prog to NULL so bpf_link_free
won't call link->ops->release, but will call link->ops->dealloc,
so it should be fine AFAICS
jirka
>
> > bpf_link_cleanup(&link_primer);
> > return err;
> > }
> > --
> > 2.37.3
> >
next prev parent reply other threads:[~2022-10-24 8:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 13:56 [PATCHv2 bpf-next 0/8] bpf: Fixes for kprobe multi on kernel modules Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 1/8] kallsyms: Make module_kallsyms_on_each_symbol generally available Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 2/8] ftrace: Add support to resolve module symbols in ftrace_lookup_symbols Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 3/8] bpf: Rename __bpf_kprobe_multi_cookie_cmp to bpf_kprobe_multi_addrs_cmp Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 4/8] bpf: Take module reference on kprobe_multi link Jiri Olsa
2022-10-21 22:02 ` Andrii Nakryiko
2022-10-24 8:16 ` Jiri Olsa [this message]
2022-10-24 18:17 ` Andrii Nakryiko
2022-10-21 22:07 ` Andrii Nakryiko
2022-10-24 8:17 ` Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 5/8] selftests/bpf: Add load_kallsyms_refresh function Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 6/8] selftests/bpf: Add bpf_testmod_fentry_* functions Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 7/8] selftests/bpf: Add kprobe_multi check to module attach test Jiri Olsa
2022-10-19 13:56 ` [PATCHv2 bpf-next 8/8] selftests/bpf: Add kprobe_multi kmod attach api tests Jiri Olsa
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=Y1ZJwOR0rLIkGzVa@krava \
--to=olsajiri@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=hch@lst.de \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=m@lambda.lt \
--cc=mhiramat@kernel.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=songliubraving@fb.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.