From: Eduard Zingerman <eddyz87@gmail.com>
To: bot+bpf-ci@kernel.org, memxor@gmail.com, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
emil@etsalapatis.com, tj@kernel.org, ameryhung@gmail.com,
kkd@meta.com, kernel-team@meta.com, martin.lau@kernel.org,
yonghong.song@linux.dev, mason@kernel.org,
ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v4 2/8] bpf: Record raw memory arguments during argument checking
Date: Fri, 18 Sep 2026 09:24:47 -0700 [thread overview]
Message-ID: <f4f90cfb55d6275f552fc3ad619f35ef64901cbe.camel@gmail.com> (raw)
In-Reply-To: <0ddd64a1da65d48b189f5a88ccee3d5544fb503c715d4881bc63b8176cb27a54@mail.kernel.org>
On Fri, 2026-09-18 at 06:35 +0000, bot+bpf-ci@kernel.org wrote:
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index 6c6b8d8520cdf..1d5e4ee64fc00 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
>
> [ ... ]
>
> > @@ -7215,7 +7215,8 @@ static int check_mem_size_reg(struct bpf_verifier_env *env,
> > * raw mode so that the program is required to initialize all
> > * the memory that the helper could just partially fill up.
> > */
> > - if (!tnum_is_const(size_reg->var_off))
> > + if (!tnum_is_const(size_reg->var_off) &&
> > + meta->arg_raw_mem.regno == reg_from_argno(mem_argno))
> > meta->arg_raw_mem.regno = 0;
>
> This isn't a bug, but would it help to say which helpers this actually
> changes (bpf_strtol/bpf_strtoul/bpf_kallsyms_lookup_name, where the
> unrelated variable-length input is checked before the output is recorded)
> and that the effect is to stop withdrawing raw mode from their output
> buffer?
>
> The commit message states that an unrelated memory argument must not
> discard the output's identity after its initialization size has been
> recorded. Scanning the existing helper protos, the three that have both
> an unrelated variable-size pair and a MEM_UNINIT output all place the
> variable-size input before the output:
>
> bpf_strtol_proto / bpf_strtoul_proto (kernel/bpf/helpers.c)
> bpf_kallsyms_lookup_name_proto (kernel/bpf/syscall.c)
> .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY,
> .arg2_type = ARG_MEM_SIZE[_OR_ZERO],
> .arg4_type = ARG_PTR_TO_FIXED_SIZE_MEM | MEM_UNINIT | ...
>
> So the observable effect today is the opposite ordering: a variable
> buf_len / name_sz no longer withdraws raw mode from the arg4 output
> buffer.
Extending the commit message might make sense.
> [ ... ]
>
> > @@ -8929,6 +8930,11 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
> > if (err)
> > return err;
> >
> > + if (!meta->btf && (arg_type & MEM_UNINIT) &&
> > + (base_type(arg_type) == ARG_PTR_TO_MEM ||
> > + base_type(arg_type) == ARG_PTR_TO_MAP_VALUE))
> > + meta->arg_raw_mem.regno = slot + 1;
>
> This isn't a bug, but could this reuse arg_type_is_raw_mem() (defined at
> verifier.c:8155) so the recording site and check_raw_mode_ok() share one
> definition of a raw memory argument, or are the two predicates meant to
> diverge later in the series?
>
> The new predicate is term-for-term the body of arg_type_is_raw_mem():
>
> static bool arg_type_is_raw_mem(enum bpf_arg_type type)
> {
> return (base_type(type) == ARG_PTR_TO_MEM ||
> base_type(type) == ARG_PTR_TO_MAP_VALUE) &&
> type & MEM_UNINIT;
> }
>
> which is still used by check_raw_mode_ok().
Let's indeed reuse the helper.
...
next prev parent reply other threads:[~2026-09-18 16:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 5:28 [PATCH bpf-next v4 0/8] Fix generic __uninit kfunc output buffers Kumar Kartikeya Dwivedi
2026-09-18 5:28 ` [PATCH bpf-next v4 1/8] selftests/bpf: Allow privileged preparation for capability tests Kumar Kartikeya Dwivedi
2026-09-18 5:28 ` [PATCH bpf-next v4 2/8] bpf: Record raw memory arguments during argument checking Kumar Kartikeya Dwivedi
2026-09-18 6:35 ` bot+bpf-ci
2026-09-18 16:24 ` Eduard Zingerman [this message]
2026-09-18 5:28 ` [PATCH bpf-next v4 3/8] bpf: Check read access for initialized writable memory arguments Kumar Kartikeya Dwivedi
2026-09-18 5:50 ` sashiko-bot
2026-09-18 17:46 ` Eduard Zingerman
2026-09-18 18:01 ` Amery Hung
2026-09-18 5:28 ` [PATCH bpf-next v4 4/8] selftests/bpf: Cover helper memory access permissions Kumar Kartikeya Dwivedi
2026-09-18 6:17 ` bot+bpf-ci
2026-09-18 5:28 ` [PATCH bpf-next v4 5/8] bpf: Fix generic __uninit kfunc output buffers Kumar Kartikeya Dwivedi
2026-09-18 6:35 ` bot+bpf-ci
2026-09-18 17:50 ` Eduard Zingerman
2026-09-18 5:29 ` [PATCH bpf-next v4 6/8] selftests/bpf: Cover generic __uninit output initialization Kumar Kartikeya Dwivedi
2026-09-18 5:29 ` [PATCH bpf-next v4 7/8] bpf: Support multiple __uninit kfunc output arguments Kumar Kartikeya Dwivedi
2026-09-18 5:29 ` [PATCH bpf-next v4 8/8] selftests/bpf: Cover __uninit kfunc output argument slots Kumar Kartikeya Dwivedi
2026-09-18 6:35 ` bot+bpf-ci
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=f4f90cfb55d6275f552fc3ad619f35ef64901cbe.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
--cc=memxor@gmail.com \
--cc=tj@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