BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Mykyta Yatsenko <mykyta.yatsenko5@gmail.com>,
	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>,
		kernel-team@meta.com
Subject: Re: [PATCH bpf-next v3 2/6] bpf: consolidate sleepable context error message printing
Date: Mon, 23 Feb 2026 12:27:36 -0800	[thread overview]
Message-ID: <c3ada08c5f362b0a378ea7bde84b20f920af6b1a.camel@gmail.com> (raw)
In-Reply-To: <87y0kjb4yf.fsf@gmail.com>

On Mon, 2026-02-23 at 20:06 +0000, Mykyta Yatsenko wrote:
> Puranjay Mohan <puranjay@kernel.org> writes:
>
> > check_helper_call() prints the error message for every
> > env->cur_state->active* element when calling a sleepable helper.
> > Consolidate all of them into a single print statement.
> >
> > Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> > ---
> >  kernel/bpf/verifier.c | 40 ++++++++++++++++++----------------------
> >  1 file changed, 18 insertions(+), 22 deletions(-)
> >
> > diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> > index c693dd663cab..c2a63f8c8984 100644
> > --- a/kernel/bpf/verifier.c
> > +++ b/kernel/bpf/verifier.c
> > @@ -11574,6 +11574,19 @@ static inline bool in_sleepable_context(struct bpf_verifier_env *env)
> >  	       in_sleepable(env);
> >  }
> >
> > +static const char *non_sleepable_context_description(struct bpf_verifier_env *env)
> > +{
> > +	if (env->cur_state->active_rcu_locks)
> > +		return "rcu_read_lock region";
> > +	if (env->cur_state->active_preempt_locks)
> > +		return "non-preemptible region";
> > +	if (env->cur_state->active_irq_id)
> > +		return "IRQ-disabled region";
> > +	if (env->cur_state->active_locks)
> > +		return "lock region";
> This check didn't exist before, did it? It looks right, but adding
> something into the commit message to explain this would be nice.
> Does it mean we can currently call a sleepable helper in the lock
> region?

This triggered me as well. Claude pointed here:

  >   The restriction is at verifier.c:20999–21007, in do_check() — before check_helper_call() is even reached:
  >   if (env->cur_state->active_locks) {
  >       if ((insn->src_reg == BPF_REG_0 &&
  >            insn->imm != BPF_FUNC_spin_unlock) ||
  >           (insn->src_reg == BPF_PSEUDO_KFUNC_CALL &&
  >            (insn->off != 0 || !kfunc_spin_allowed(insn->imm)))) {
  >           verbose(env,
  >               "function calls are not allowed while holding a lock\n");
  >           return -EINVAL;
  >       }
  >   }

Commenting about it in the commit message would be helpful 100%.

> > +	return "non-sleepable context";
> > +}
> > +

[...]

  reply	other threads:[~2026-02-23 20:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-23 17:46 [PATCH bpf-next v3 0/6] Introduce KF_FORBID_SLEEP modifier for acquire/release kfuncs Puranjay Mohan
2026-02-23 17:46 ` [PATCH bpf-next v3 1/6] bpf: Add KF_ACQUIRE and KF_RELEASE support for iterators Puranjay Mohan
2026-02-23 19:59   ` Mykyta Yatsenko
2026-02-23 20:41   ` Eduard Zingerman
2026-02-23 17:46 ` [PATCH bpf-next v3 2/6] bpf: consolidate sleepable context error message printing Puranjay Mohan
2026-02-23 20:06   ` Mykyta Yatsenko
2026-02-23 20:27     ` Eduard Zingerman [this message]
2026-02-23 17:46 ` [PATCH bpf-next v3 3/6] bpf: Add KF_FORBID_SLEEP modifier for KF_ACQUIRE kfuncs Puranjay Mohan
2026-02-23 22:14   ` Eduard Zingerman
2026-02-24 15:24     ` Puranjay Mohan
2026-02-24 18:17       ` Eduard Zingerman
2026-02-24 19:41         ` Kumar Kartikeya Dwivedi
2026-02-23 17:46 ` [PATCH bpf-next v3 4/6] bpf: Move locking to bpf_iter_task_vma_next() Puranjay Mohan
2026-02-23 17:46 ` [PATCH bpf-next v3 5/6] bpf: Add split iteration support to task_vma iterator Puranjay Mohan
2026-02-23 17:46 ` [PATCH bpf-next v3 6/6] selftests/bpf: Add tests for split " Puranjay Mohan
2026-02-24  1:49 ` [PATCH bpf-next v3 0/6] Introduce KF_FORBID_SLEEP modifier for acquire/release kfuncs Alexei Starovoitov
2026-02-24 11:24   ` Puranjay Mohan
2026-02-24 18:00     ` Alexei Starovoitov
2026-02-24 18:55       ` Eduard Zingerman
2026-02-24 19:32         ` Alexei Starovoitov
2026-02-24 19:47           ` Puranjay Mohan
2026-02-24 19:51         ` Puranjay Mohan
2026-02-24 20:15           ` Eduard Zingerman
2026-02-24 20:20             ` 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=c3ada08c5f362b0a378ea7bde84b20f920af6b1a.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