BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>, <bpf@vger.kernel.org>
Cc: "Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"Ihor Solodrai" <ihor.solodrai@linux.dev>,
	"Tejun Heo" <tj@kernel.org>, <kkd@meta.com>,
	<kernel-team@meta.com>
Subject: Re: [PATCH bpf-next v3 12/15] bpf: Set up the arena base only in functions that use it
Date: Fri, 16 Oct 2026 01:13:36 +0000	[thread overview]
Message-ID: <DM5V45Y5ZYRA.17X2LC1YRCS1N@gmail.com> (raw)
In-Reply-To: <20261015234125.3152346-13-memxor@gmail.com>

On Fri, Oct 16, 2026 at 01:41 AM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
> @@ -9919,6 +9933,9 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, u32 slot, u32 p
>  		}
>  		break;
>  	case ARG_PTR_TO_ARENA:
> +		/* the JIT rebases the __arena argument of a kfunc on the arena base */
> +		if (is_kfunc(meta))
> +			mark_uses_arena_insn(env);
>  		break;

This mark is not reached when the prog passes 0.
is_kfunc_arg_nullable() is true for both __arena and __arena__nullable,
so arg_type is ARG_PTR_TO_ARENA | PTR_MAYBE_NULL and
check_func_arg() returns at

	if (bpf_register_is_null(reg) && type_may_be_null(arg_type)) {

before the switch.

  SEC("syscall")
  int prog(void *ctx)
  {
	return bpf_kfunc_arena_cap_test(NULL) != 0;
  }

is not marked, but the func model has BTF_FMODEL_ARENA_ARG, so
emit_kfunc_arena_args() hits
WARN_ON_ONCE(!bpf_prog_uses_arena_insns(bpf_prog))
and the prog is rejected.

v1 was marking the wrong subprog in the same spot.
This spot has a WARN. When a mark is missed for ldx or stx
JIT emits [r12 + reg] with r12 of the caller.

Can bpf_prog_uses_arena_insns() look at the final insns instead?
Like detect_reg_usage() does for callee saved regs.
jit_subprogs() already looks for PROBE_MEM32 and PROBE_ATOMIC
in every func to count exentries.
Then no marks in the verifier.

pw-bot: cr

  reply	other threads:[~2026-10-16  1:13 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 23:41 [PATCH bpf-next v3 00/15] Fix some arena paper cuts Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 01/15] bpf: Compute the program digest before resolving the fd_array Kumar Kartikeya Dwivedi
2026-10-16  0:28   ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 02/15] selftests/bpf: Bind an exclusive map through a continuous fd_array Kumar Kartikeya Dwivedi
2026-10-15 23:53   ` sashiko-bot
2026-10-16  0:00     ` Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 03/15] libbpf: Keep the fd_array fill index out of bpf_program__clone() Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 04/15] selftests/bpf: Clone a program that calls a module kfunc Kumar Kartikeya Dwivedi
2026-10-16  0:12   ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 05/15] compiler_types: Add __arena and __nullable BTF type tag qualifiers Kumar Kartikeya Dwivedi
2026-10-16  1:08   ` Alexei Starovoitov
2026-10-16  1:15     ` Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 06/15] bpf: Recognize __nullable on pointer members of kernel structs Kumar Kartikeya Dwivedi
2026-10-15 23:54   ` sashiko-bot
2026-10-16  0:00     ` Kumar Kartikeya Dwivedi
2026-10-16  1:09   ` Alexei Starovoitov
2026-10-16  1:24     ` Kumar Kartikeya Dwivedi
2026-10-16  1:31       ` Alexei Starovoitov
2026-10-16  1:39         ` Kumar Kartikeya Dwivedi
2026-10-16  1:53           ` Alexei Starovoitov
2026-10-16  2:04             ` Kumar Kartikeya Dwivedi
2026-10-16  2:20               ` Alexei Starovoitov
2026-10-15 23:41 ` [PATCH bpf-next v3 07/15] bpf: Turn loads of __arena pointer members into arena pointers Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 08/15] selftests/bpf: Test __nullable pointer members Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 09/15] selftests/bpf: Test __arena " Kumar Kartikeya Dwivedi
2026-10-16  1:11   ` Alexei Starovoitov
2026-10-16  1:39     ` Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 10/15] libbpf: Bind the arena of an object to every program in it Kumar Kartikeya Dwivedi
2026-10-16  0:28   ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 11/15] selftests/bpf: Test arena binding by libbpf Kumar Kartikeya Dwivedi
2026-10-16  0:28   ` bot+bpf-ci
2026-10-15 23:41 ` [PATCH bpf-next v3 12/15] bpf: Set up the arena base only in functions that use it Kumar Kartikeya Dwivedi
2026-10-16  1:13   ` Alexei Starovoitov [this message]
2026-10-15 23:41 ` [PATCH bpf-next v3 13/15] libbpf: Render the arena type tag with its address space Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 14/15] selftests/bpf: Test the address space rendering of the arena type tag Kumar Kartikeya Dwivedi
2026-10-15 23:41 ` [PATCH bpf-next v3 15/15] selftests/bpf: Test an arena kfunc argument passed from a subprogram Kumar Kartikeya Dwivedi

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=DM5V45Y5ZYRA.17X2LC1YRCS1N@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=kernel-team@meta.com \
    --cc=kkd@meta.com \
    --cc=memxor@gmail.com \
    --cc=tj@kernel.org \
    /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