From: Jiri Olsa <olsajiri@gmail.com>
To: Xu Kuohai <xukuohai@huaweicloud.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, 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>,
Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
Hou Tao <houtao1@huawei.com>,
Dmitrii Dolgov <9erthalion6@gmail.com>,
Alan Maguire <alan.maguire@oracle.com>,
Kui-Feng Lee <kuifeng@fb.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Subject: Re: [PATCH bpf-next 4/5] selftest/bpf: Fix memory leak in kprobe_multi_test
Date: Mon, 10 Oct 2022 11:01:23 +0200 [thread overview]
Message-ID: <Y0PfY9irDM0KEqq7@krava> (raw)
In-Reply-To: <20221009131830.395569-5-xukuohai@huaweicloud.com>
On Sun, Oct 09, 2022 at 09:18:29AM -0400, Xu Kuohai wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
>
> The get_syms() function in kprobe_multi_test.c does not free the string
> memory allocated by sscanf correctly. Fix it.
>
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
> ---
> .../bpf/prog_tests/kprobe_multi_test.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> index d457a55ff408..07dd2c5b7f98 100644
> --- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> +++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c
> @@ -360,15 +360,14 @@ static int get_syms(char ***symsp, size_t *cntp)
> * to them. Filter out the current culprits - arch_cpu_idle
> * and rcu_* functions.
> */
> - if (!strcmp(name, "arch_cpu_idle"))
> - continue;
> - if (!strncmp(name, "rcu_", 4))
> - continue;
> - if (!strcmp(name, "bpf_dispatcher_xdp_func"))
> - continue;
> - if (!strncmp(name, "__ftrace_invalid_address__",
> - sizeof("__ftrace_invalid_address__") - 1))
> + if (!strcmp(name, "arch_cpu_idle") ||
> + !strncmp(name, "rcu_", 4) ||
> + !strcmp(name, "bpf_dispatcher_xdp_func") ||
> + !strncmp(name, "__ftrace_invalid_address__",
> + sizeof("__ftrace_invalid_address__") - 1)) {
> + free(name);
> continue;
> + }
> err = hashmap__add(map, name, NULL);
> if (err) {
> free(name);
> @@ -394,7 +393,7 @@ static int get_syms(char ***symsp, size_t *cntp)
> hashmap__free(map);
> if (err) {
> for (i = 0; i < cnt; i++)
> - free(syms[cnt]);
> + free(syms[i]);
mama mia.. nice catch! thanks
Acked-by: Jiri Olsa <jolsa@kernel.org>
jirka
> free(syms);
> }
> return err;
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-10-10 9:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-09 13:18 [PATCH bpf-next 0/5] Fix bugs found by ASAN when running selftests Xu Kuohai
2022-10-09 13:18 ` [PATCH bpf-next 1/5] libbpf: Fix use-after-free in btf_dump_name_dups Xu Kuohai
2022-10-09 13:18 ` [PATCH bpf-next 2/5] libbpf: Fix memory leak in parse_usdt_arg() Xu Kuohai
2022-10-09 13:18 ` [PATCH bpf-next 3/5] selftests/bpf: Fix memory leak caused by not destroying skeleton Xu Kuohai
2022-10-09 13:18 ` [PATCH bpf-next 4/5] selftest/bpf: Fix memory leak in kprobe_multi_test Xu Kuohai
2022-10-10 9:01 ` Jiri Olsa [this message]
2022-10-09 13:18 ` [PATCH bpf-next 5/5] selftest/bpf: Fix error usage of ASSERT_OK in xdp_adjust_tail.c Xu Kuohai
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=Y0PfY9irDM0KEqq7@krava \
--to=olsajiri@gmail.com \
--cc=9erthalion6@gmail.com \
--cc=alan.maguire@oracle.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=houtao1@huawei.com \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=kuifeng@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=xukuohai@huaweicloud.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.