BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Puranjay Mohan <puranjay@kernel.org>, bpf@vger.kernel.org
Cc: Puranjay Mohan <puranjay12@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau	 <martin.lau@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
	kernel-team@meta.com
Subject: Re: [PATCH bpf-next 1/5] bpf: Add KF_ACQUIRE and KF_RELEASE support for iterators
Date: Thu, 19 Feb 2026 12:37:52 -0800	[thread overview]
Message-ID: <b36ca4ba2eada11a9b5cd5dc1f44e9217a86add3.camel@gmail.com> (raw)
In-Reply-To: <20260218182555.1501495-2-puranjay@kernel.org>

On Wed, 2026-02-18 at 10:25 -0800, Puranjay Mohan wrote:

[...]

> @@ -13797,7 +13826,7 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_kfunc_call_
>  		}
>  	}
>  
> -	if (is_kfunc_release(meta) && !meta->release_regno) {
> +	if (is_kfunc_release(meta) && !meta->release_regno && !meta->has_iter_arg) {

This makes the check too strict, right?
E.g. for most of the release kfuncs there would be no iter arg,
hence the check won't ever be true for those kfuncs.
Do we have tests for this check?
Either we don't have the tests or the check itself is redundant.

>  		verbose(env, "release kernel function %s expects refcounted PTR_TO_BTF_ID\n",
>  			func_name);
>  		return -EINVAL;

[...]

> @@ -14356,6 +14400,18 @@ static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
>  			regs[BPF_REG_0].id = ++env->id_gen;
>  		}
>  		mark_btf_func_reg_size(env, BPF_REG_0, sizeof(void *));
> +		/* For iterators with KF_ACQUIRE, auto-release the previous
> +		 * iteration's ref before acquiring a new one, and after
> +		 * acquisition track the new ref on the iter slot.
> +		 */
> +		struct bpf_reg_state *iter_acquire_st = NULL;
> +
> +		if (is_iter_next_kfunc(&meta) && is_kfunc_acquire(&meta)) {
> +			iter_acquire_st = get_iter_from_state(env->cur_state, &meta);
> +			err = iter_release_acquired_ref(env, iter_acquire_st);
> +			if (err)
> +				return err;
> +		}

I second Mykyta's points here.

[...]

  parent reply	other threads:[~2026-02-19 20:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-18 18:25 [PATCH bpf-next 0/5] Introduce KF_FORBID_SLEEP modifier for acquire/release kfuncs Puranjay Mohan
2026-02-18 18:25 ` [PATCH bpf-next 1/5] bpf: Add KF_ACQUIRE and KF_RELEASE support for iterators Puranjay Mohan
2026-02-19 17:45   ` Mykyta Yatsenko
2026-02-19 20:37   ` Eduard Zingerman [this message]
2026-02-20  1:05     ` Puranjay Mohan
2026-02-20  1:09       ` Eduard Zingerman
2026-02-18 18:25 ` [PATCH bpf-next 2/5] bpf: Add KF_FORBID_SLEEP modifier for KF_ACQUIRE kfuncs Puranjay Mohan
2026-02-19  3:24   ` Alexei Starovoitov
2026-02-20  0:14     ` Puranjay Mohan
2026-02-19 22:19   ` Eduard Zingerman
2026-02-20  0:51     ` Puranjay Mohan
2026-02-18 18:25 ` [PATCH bpf-next 3/5] bpf: Move locking to bpf_iter_task_vma_next() Puranjay Mohan
2026-02-18 18:25 ` [PATCH bpf-next 4/5] bpf: Add split iteration support to task_vma iterator Puranjay Mohan
2026-02-18 18:25 ` [PATCH bpf-next 5/5] selftests/bpf: Add tests for split " Puranjay Mohan

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=b36ca4ba2eada11a9b5cd5dc1f44e9217a86add3.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=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=mykyta.yatsenko5@gmail.com \
    --cc=puranjay12@gmail.com \
    --cc=puranjay@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