From: Eduard Zingerman <eddyz87@gmail.com>
To: Amery Hung <ameryhung@gmail.com>, bpf@vger.kernel.org
Cc: alexei.starovoitov@gmail.com, andrii@kernel.org,
daniel@iogearbox.net, memxor@gmail.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v1 4/4] bpf: Unify helper and kfunc call argument meta
Date: Tue, 14 Jul 2026 11:48:45 -0700 [thread overview]
Message-ID: <08cc4cf4992b72088e59cd9aafe2bfa78d87f738.camel@gmail.com> (raw)
In-Reply-To: <20260709230242.2003459-5-ameryhung@gmail.com>
On Thu, 2026-07-09 at 16:02 -0700, Amery Hung wrote:
> Helper and kfunc argument checking carried two separate meta structs: the
> verifier-local struct bpf_call_arg_meta and bpf_kfunc_call_arg_meta.
> Merge them into a single struct bpf_call_arg_meta. This is groundwork for
> sharing argument checking between helpers and kfuncs.
>
> While merging, drop the btf_id field from the helper meta since it is
> never used.
>
> No functional change.
>
> Signed-off-by: Amery Hung <ameryhung@gmail.com>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
> include/linux/bpf_verifier.h | 40 +++++++++------
> kernel/bpf/cfg.c | 2 +-
> kernel/bpf/verifier.c | 95 +++++++++++++++---------------------
> 3 files changed, 63 insertions(+), 74 deletions(-)
>
> diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
> index 3ed788ec6afc..5fbc3dfe5b19 100644
> --- a/include/linux/bpf_verifier.h
> +++ b/include/linux/bpf_verifier.h
> @@ -1479,18 +1479,24 @@ struct arg_alloc_mem_desc {
> bool found;
> };
>
> -struct bpf_kfunc_call_arg_meta {
> - /* In parameters */
> +struct bpf_call_arg_meta {
> + /* Common */
> struct btf *btf;
> u32 func_id;
> - u32 kfunc_flags;
> - const struct btf_type *func_proto;
> - const char *func_name;
> - /* Out parameters */
> u8 release_regno;
> - bool r0_rdonly;
> u32 ret_btf_id;
> u32 subprogno;
> + struct bpf_map_desc map;
> + struct bpf_dynptr_desc dynptr;
> + struct ref_obj_desc ref_obj;
> + struct arg_raw_mem_desc arg_raw_mem;
> + struct arg_alloc_mem_desc arg_alloc_mem;
> +
> + /* Only set by kfunc */
> + bool r0_rdonly;
> + u32 kfunc_flags;
> + const struct btf_type *func_proto;
> + const char *func_name;
> struct {
> u64 value;
> bool found;
> @@ -1521,29 +1527,31 @@ struct bpf_kfunc_call_arg_meta {
> u8 spi;
> u8 frameno;
> } iter;
> - struct bpf_map_desc map;
> - struct bpf_dynptr_desc dynptr;
> - struct ref_obj_desc ref_obj;
> - struct arg_raw_mem_desc arg_raw_mem;
> - struct arg_alloc_mem_desc arg_alloc_mem;
> +
> + /* Only set by helper */
> + bool pkt_access;
It appears this one can be dropped altogether:
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5ccb00a8c84c..b1d5a359c78b 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -4654,7 +4654,7 @@ static int check_map_access(struct bpf_verifier_env *env, struct bpf_reg_state *
}
static bool may_access_direct_pkt_data(struct bpf_verifier_env *env,
- const struct bpf_call_arg_meta *meta,
+ const struct bpf_func_proto *fn,
enum bpf_access_type t)
{
enum bpf_prog_type prog_type = resolve_prog_type(env->prog);
@@ -4678,8 +4678,8 @@ static bool may_access_direct_pkt_data(struct bpf_verifier_env *env,
case BPF_PROG_TYPE_LWT_XMIT:
case BPF_PROG_TYPE_SK_SKB:
case BPF_PROG_TYPE_SK_MSG:
- if (meta)
- return meta->pkt_access;
+ if (fn)
+ return fn->pkt_access;
env->seen_direct_write = true;
return true;
@@ -8307,7 +8307,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
}
if (type_is_pkt_pointer(type) &&
- !may_access_direct_pkt_data(env, meta, BPF_READ)) {
+ !may_access_direct_pkt_data(env, fn, BPF_READ)) {
verbose(env, "helper access to the packet is not allowed\n");
return -EACCES;
}
> + u64 msize_max_value;
> + s64 const_map_key;
> + struct btf *ret_btf;
> + struct btf_field *kptr_field;
> };
[...]
prev parent reply other threads:[~2026-07-14 18:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 23:02 [PATCH bpf-next v1 0/4] Unify helper and kfunc call_arg_meta Amery Hung
2026-07-09 23:02 ` [PATCH bpf-next v1 1/4] bpf: Remove dynptr check in check_stack_range_initialized() Amery Hung
2026-07-13 23:41 ` Eduard Zingerman
2026-07-09 23:02 ` [PATCH bpf-next v1 2/4] bpf: Factor out raw_mode-related fields in bpf_call_arg_meta Amery Hung
2026-07-09 23:17 ` sashiko-bot
2026-07-09 23:36 ` Amery Hung
2026-07-14 0:08 ` Eduard Zingerman
2026-07-14 23:22 ` Amery Hung
2026-07-09 23:02 ` [PATCH bpf-next v1 3/4] bpf: Unify helper and kfunc allocation-size argument handling Amery Hung
2026-07-10 0:02 ` bot+bpf-ci
2026-07-14 18:14 ` Eduard Zingerman
2026-07-09 23:02 ` [PATCH bpf-next v1 4/4] bpf: Unify helper and kfunc call argument meta Amery Hung
2026-07-09 23:16 ` sashiko-bot
2026-07-09 23:44 ` Amery Hung
2026-07-14 18:48 ` Eduard Zingerman [this message]
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=08cc4cf4992b72088e59cd9aafe2bfa78d87f738.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=memxor@gmail.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