From: Eduard Zingerman <eddyz87@gmail.com>
To: Qianfeng Rong <rongqianfeng@vivo.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bpf: replace kvfree with kfree for kzalloc memory
Date: Mon, 11 Aug 2025 09:46:33 -0700 [thread overview]
Message-ID: <6b72f32a9d1b137fb3f3ae0c439b1688fef8dd8d.camel@gmail.com> (raw)
In-Reply-To: <20250811123949.552885-1-rongqianfeng@vivo.com>
On Mon, 2025-08-11 at 20:39 +0800, Qianfeng Rong wrote:
> The 'backedge' pointer is allocated with kzalloc(), which returns
> physically contiguous memory. Using kvfree() to deallocate such
> memory is functionally safe but semantically incorrect.
>
> Replace kvfree() with kfree() to avoid unnecessary is_vmalloc_addr()
> check in kvfree().
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> kernel/bpf/verifier.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index c4f69a9e9af6..4e5de1ff7e30 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -19553,7 +19553,7 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
> err = err ?: add_scc_backedge(env, &sl->state, backedge);
> if (err) {
> free_verifier_state(&backedge->state, false);
> - kvfree(backedge);
> + kfree(backedge);
The backedge encapsulates verifier state, verifier states are
allocated using kzalloc() and freed using kfreed() in other places in
verifier.c => I think this patch is valid.
> return err;
> }
> }
next prev parent reply other threads:[~2025-08-11 16:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 12:39 [PATCH] bpf: replace kvfree with kfree for kzalloc memory Qianfeng Rong
2025-08-11 13:15 ` Qianfeng Rong
2025-08-11 16:47 ` Eduard Zingerman
2025-08-11 13:25 ` Markus Elfring
2025-08-11 16:46 ` Eduard Zingerman [this message]
2025-08-12 23:00 ` patchwork-bot+netdevbpf
-- strict thread matches above, loose matches on Subject: below --
2025-08-26 7:39 [PATCH] bpf: Replace " Feng Yang
2025-08-26 11:43 ` Daniel Borkmann
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=6b72f32a9d1b137fb3f3ae0c439b1688fef8dd8d.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=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=rongqianfeng@vivo.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).