From: Eduard Zingerman <eddyz87@gmail.com>
To: Hou Tao <houtao@huaweicloud.com>, bpf@vger.kernel.org
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>,
Hao Luo <haoluo@google.com>,
Yonghong Song <yonghong.song@linux.dev>,
Daniel Borkmann <daniel@iogearbox.net>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
houtao1@huawei.com, xukuohai@huawei.com
Subject: Re: [PATCH bpf-next 03/16] bpf: Parse bpf_dynptr in map key
Date: Thu, 10 Oct 2024 11:02:37 -0700 [thread overview]
Message-ID: <47dda61b85917e864eab5cde7e16723a5884ce69.camel@gmail.com> (raw)
In-Reply-To: <20241008091501.8302-4-houtao@huaweicloud.com>
On Tue, 2024-10-08 at 17:14 +0800, Hou Tao wrote:
[...]
> diff --git a/kernel/bpf/map_in_map.c b/kernel/bpf/map_in_map.c
> index 645bd30bc9a9..a072835dc645 100644
> --- a/kernel/bpf/map_in_map.c
> +++ b/kernel/bpf/map_in_map.c
[...]
> @@ -45,9 +45,13 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
> * invalid/empty/valid, but ERR_PTR in case of errors. During
> * equality NULL or IS_ERR is equivalent.
> */
> - struct bpf_map *ret = ERR_CAST(inner_map_meta->record);
> - kfree(inner_map_meta);
> - return ret;
> + ret = ERR_CAST(inner_map_meta->record);
> + goto free;
> + }
> + inner_map_meta->key_record = btf_record_dup(inner_map->key_record);
> + if (IS_ERR(inner_map_meta->key_record)) {
> + ret = ERR_CAST(inner_map_meta->key_record);
> + goto free;
The 'goto free' executes a call to bpf_map_meta_free() which does
btf_put(map_meta->btf), but corresponding btf_get(inner_map->btf) only
happens on the lines below => in case when 'free' branch is taken we
'put' BTF object that was not 'get' by us.
> }
> /* Note: We must use the same BTF, as we also used btf_record_dup above
> * which relies on BTF being same for both maps, as some members like
> @@ -71,6 +75,10 @@ struct bpf_map *bpf_map_meta_alloc(int inner_map_ufd)
> inner_map_meta->bypass_spec_v1 = inner_map->bypass_spec_v1;
> }
> return inner_map_meta;
> +
> +free:
> + bpf_map_meta_free(inner_map_meta);
> + return ret;
> }
>
> void bpf_map_meta_free(struct bpf_map *map_meta)
[...]
next prev parent reply other threads:[~2024-10-10 18:02 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 9:14 [PATCH bpf-next 00/16] Support dynptr key for hash map Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 01/16] bpf: Introduce map flag BPF_F_DYNPTR_IN_KEY Hou Tao
2024-10-10 2:21 ` Alexei Starovoitov
2024-10-21 13:45 ` Hou Tao
2024-10-22 3:53 ` Alexei Starovoitov
2024-10-22 4:22 ` Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 02/16] bpf: Add two helpers to facilitate the btf parsing of bpf_dynptr Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 03/16] bpf: Parse bpf_dynptr in map key Hou Tao
2024-10-10 18:02 ` Eduard Zingerman [this message]
2024-10-21 13:48 ` Hou Tao
2024-10-11 16:29 ` Alexei Starovoitov
2024-10-21 14:02 ` Hou Tao
2024-10-22 3:59 ` Alexei Starovoitov
2024-10-22 7:20 ` Hou Tao
2024-10-22 18:44 ` Alexei Starovoitov
2024-10-08 9:14 ` [PATCH bpf-next 04/16] bpf: Pass flags instead of bool to check_helper_mem_access() Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 05/16] bpf: Support map key with dynptr in verifier Hou Tao
2024-10-10 20:30 ` Eduard Zingerman
2024-10-10 20:57 ` Eduard Zingerman
2024-10-21 13:50 ` Hou Tao
2024-10-13 13:07 ` Dan Carpenter
2024-10-31 2:39 ` Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 06/16] bpf: Introduce bpf_dynptr_user Hou Tao
2024-10-10 21:50 ` Andrii Nakryiko
2024-10-10 22:12 ` Alexei Starovoitov
2024-10-21 13:51 ` Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 07/16] libbpf: Add helpers for bpf_dynptr_user Hou Tao
2024-10-10 21:50 ` Andrii Nakryiko
2024-10-21 13:51 ` Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 08/16] bpf: Handle bpf_dynptr_user in bpf syscall when it is used as input Hou Tao
2024-10-13 13:08 ` Dan Carpenter
2024-10-31 2:44 ` Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 09/16] bpf: Handle bpf_dynptr_user in bpf syscall when it is used as output Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 10/16] bpf: Disable unsupported functionalities for map with dynptr key Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 11/16] bpf: Add bpf_mem_alloc_check_size() helper Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 12/16] bpf: Support basic operations for dynptr key in hash map Hou Tao
2024-10-11 16:47 ` Alexei Starovoitov
2024-10-30 10:02 ` Hou Tao
2024-11-02 18:31 ` Alexei Starovoitov
2024-10-08 9:14 ` [PATCH bpf-next 13/16] bpf: Export bpf_dynptr_set_size Hou Tao
2024-10-08 9:14 ` [PATCH bpf-next 14/16] bpf: Support get_next_key operation for dynptr key in hash map Hou Tao
2024-10-08 9:15 ` [PATCH bpf-next 15/16] bpf: Enable BPF_F_DYNPTR_IN_KEY for " Hou Tao
2024-10-08 9:15 ` [PATCH bpf-next 16/16] selftests/bpf: Add test cases for hash map with dynptr key Hou Tao
2024-10-11 18:23 ` Alexei Starovoitov
2024-10-21 14:05 ` Hou Tao
2024-10-11 22:11 ` [PATCH bpf-next 00/16] Support dynptr key for hash map Eduard Zingerman
2024-10-21 14:09 ` Hou Tao
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=47dda61b85917e864eab5cde7e16723a5884ce69.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=houtao1@huawei.com \
--cc=houtao@huaweicloud.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=xukuohai@huawei.com \
--cc=yonghong.song@linux.dev \
/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