From: Mahe Tardy <mahe.tardy@gmail.com>
To: Amery Hung <ameryhung@gmail.com>
Cc: bpf@vger.kernel.org, alexei.starovoitov@gmail.com,
andrii@kernel.org, daniel@iogearbox.net, eddyz87@gmail.com,
memxor@gmail.com, kernel-team@meta.com
Subject: Re: [PATCH bpf-next v2 19/23] bpf: Consolidate function call pkt_access validation
Date: Tue, 15 Sep 2026 12:44:25 +0200 [thread overview]
Message-ID: <aqkhifLvyAhw66jg@gmail.com> (raw)
In-Reply-To: <20260911220415.1396439-20-ameryhung@gmail.com>
On Fri, Sep 11, 2026 at 03:04:11PM -0700, Amery Hung wrote:
> check_func_arg() checks whether a helper permits packet pointers before
> dispatching argument-specific memory validation. check_kfunc_args() has
> no equivalent check, even though kfunc memory arguments may be backed by
> packet data.
>
> Move packet-access validation to check_helper_mem_access(), where the
> access direction is known and helper, kfunc, and global-subprogram memory
> arguments converge. Pass call metadata there so helpers continue to
> require bpf_func_proto::pkt_access, while writes through kfunc and global
> subprogram arguments use the program-type policy and set
> env->seen_direct_write.
>
> Keep call metadata when variable-size memory disables raw mode by
> clearing arg_raw_mem.regno instead, and pass it through the map-key path
> as well.
>
> This also makes kfunc and global-subprogram packet writes request the
> required writable-packet prologue and rejects them for program types
> that only support direct packet reads.
Hello, sorry I don't have the full context on this patch series but it
looks like this commit broke one of our programs on bpf-next, we have a
global function with the following signature in a cgroup_skb program:
__attribute__((noinline)) int
parse_something(struct __sk_buff *skb, __u16 off, char *data_start, ...)
that we call with data_start being skb->data + some_offset and now it
fails passing the verifier with:
; ret = parse_something(skb, offset_start, data, ...); @ parser.h:131
199: (bf) r2 = r8 ; R2=scalar(id=5) R8=scalar(id=5)
200: (57) r2 &= 65535 ; R2=scalar(smin=smin32=0,smax=umax=smax32=umax32=0xffff,var_off=(0x0; 0xffff))
201: (79) r1 = *(u64 *)(r10 -40) ; R1=ctx() R10=fp0 fp-40=ctx()
202: (bf) r3 = r7 ; R3=pkt(r=1247,imm=1244) R7=pkt(r=1247,imm=1244)
203: (b7) r4 = 0 ; R4=0
204: (85) call pc+776
function access to the packet is not allowed
Caller passes invalid args into func#3 ('parse_something')
And this is read-only access given it's cgroup_skb prog.
We can work around this by just passing the integer offset and re-doing
the whole skb->data + offset dance in the global function (we've been
already doing it in some other spots for function by function
verification) but I was wondering if this actually a regression or
expected, thanks.
>
> Signed-off-by: Amery Hung <ameryhung@gmail.com>
> ---
> kernel/bpf/verifier.c | 24 +++++++++----------
> .../bpf/progs/verifier_helper_packet_access.c | 4 ++--
> 2 files changed, 13 insertions(+), 15 deletions(-)
[...]
next prev parent reply other threads:[~2026-09-15 10:44 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 22:03 [PATCH bpf-next v2 00/23] Unify helper and kfunc argument checks Amery Hung
2026-09-11 22:03 ` [PATCH bpf-next v2 01/23] bpf: Pass call metadata through shared " Amery Hung
2026-09-11 22:03 ` [PATCH bpf-next v2 02/23] bpf: Address check_func_arg() arguments by argno Amery Hung
2026-09-11 22:03 ` [PATCH bpf-next v2 03/23] bpf: Only compare func_id against BPF_FUNC_* for helper calls Amery Hung
2026-09-11 22:03 ` [PATCH bpf-next v2 04/23] bpf: Only compare func_id against kfunc BTF IDs for kfunc calls Amery Hung
2026-09-11 22:03 ` [PATCH bpf-next v2 05/23] bpf: Clarify unused and scalar function argument types Amery Hung
2026-09-11 22:19 ` sashiko-bot
2026-09-11 22:03 ` [PATCH bpf-next v2 06/23] bpf: Unify kfunc argument kinds with enum bpf_arg_type Amery Hung
2026-09-11 22:26 ` sashiko-bot
2026-09-11 22:03 ` [PATCH bpf-next v2 07/23] bpf: Classify kfunc arguments the verifier ignores Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 08/23] bpf: Align helper and kfunc ARG_PTR_TO_PROG_AUX handling Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 09/23] bpf: Set OBJ_RELEASE when generating kfunc argument types Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 10/23] bpf: Set MEM_UNINIT and dynptr subtypes when generating kfunc arg types Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 11/23] bpf: Set MEM_RCU when generating kfunc argument types Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 12/23] bpf: Resolve BTF ID of ARG_PTR_TO_BTF_ID in kfunc bpf_func_proto Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 13/23] bpf: Resolve ARG_PTR_TO_MEM | MEM_FIXED_SIZE size " Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 14/23] bpf: Consolidate runtime argument type resolution Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 15/23] bpf: Consolidate nullable argument validation Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 16/23] bpf: Drop redundant BTF pointer helper write rejection Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 17/23] bpf: Consolidate helper and kfunc PTR_TO_BTF_ID argument matching Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 18/23] bpf: Admit kfunc argument registers through check_reg_type() Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 19/23] bpf: Consolidate function call pkt_access validation Amery Hung
2026-09-15 10:44 ` Mahe Tardy [this message]
2026-09-15 22:32 ` Amery Hung
2026-09-16 19:48 ` Amery Hung
2026-09-18 9:42 ` Mahe Tardy
2026-09-11 22:04 ` [PATCH bpf-next v2 20/23] selftests/bpf: Test kfunc packet memory direct writes Amery Hung
2026-09-11 22:36 ` sashiko-bot
2026-09-11 22:04 ` [PATCH bpf-next v2 21/23] bpf: Consolidate release argument validation Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 22/23] selftests/bpf: Test nullable per-CPU kptr identity after exchange Amery Hung
2026-09-11 22:04 ` [PATCH bpf-next v2 23/23] bpf: Check helper and kfunc arguments in one path Amery Hung
2026-09-12 3:20 ` [PATCH bpf-next v2 00/23] Unify helper and kfunc argument checks patchwork-bot+netdevbpf
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=aqkhifLvyAhw66jg@gmail.com \
--to=mahe.tardy@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=eddyz87@gmail.com \
--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 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.