All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Kaitao Cheng <kaitao.cheng@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	Shuah Khan <shuah@kernel.org>
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 0/3] bpf: Allow selected kfuncs under bpf_spin_lock
Date: Thu, 6 Aug 2026 00:51:08 +0800	[thread overview]
Message-ID: <b1825aab-b1d2-40c4-a74c-bb05ce50327d@linux.dev> (raw)
In-Reply-To: <20260805153340.34776-1-kaitao.cheng@linux.dev>

On 2026/8/5 23:33, Kaitao Cheng wrote:
> The verifier currently has a hard-coded allowlist of kfuncs that may be
> called while a BPF program holds a bpf_spin_lock. This works for the
> small set of built-in kfuncs known to the verifier, but it does not give
> kfunc providers a registration-time way to declare that a kfunc is safe
> in such a region. In particular, module kfuncs cannot be added to that
> allowlist without changing verifier code.
> 
> This series adds a new KF_SPINLOCK_SAFE kfunc flag and teaches the
> verifier to use kfunc registration metadata when deciding whether a
> kfunc call is allowed while a bpf_spin_lock is held.
> 
> The built-in kfuncs that are currently accepted by the verifier's
> lock-held allowlist are annotated with the new flag. This preserves the
> existing behavior while removing the verifier-side category checks and
> uses the same mechanism for built-in and module kfuncs.
> 
> The selftest coverage marks one bpf_testmod kfunc as KF_SPINLOCK_SAFE
> and verifies that it can be called under a bpf_spin_lock. It also calls
> another registered but unmarked bpf_testmod kfunc under the lock and
> checks that the verifier rejects it.
> 
> Changes in v2:
> - Rename KF_SPIN_LOCK to KF_SPINLOCK_SAFE. (Kumar Kartikeya Dwivedi,
>   Leon Hwang)
> - Deprecate the verifier's lock-held allowlist mechanism and annotate the
>   relevant kfuncs uniformly with KF_SPINLOCK_SAFE (Kumar Kartikeya Dwivedi)
> - Add selftests. (Leon Hwang)
> 
> Link to v1:
> https://lore.kernel.org/bpf/DKG0YUDSTBUY.1X220287HT9V3@gmail.com/
> 
> Kaitao Cheng (3):
>   bpf: Add KF_SPINLOCK_SAFE flag for kfuncs under bpf_spin_lock
>   bpf: Mark existing lock-safe kfuncs with KF_SPINLOCK_SAFE
>   selftests/bpf: Test module kfunc calls under spin lock
> 
>  include/linux/btf.h                           |  1 +
>  kernel/bpf/arena.c                            |  6 +-
>  kernel/bpf/helpers.c                          | 56 ++++++++++---------
>  kernel/bpf/rqspinlock.c                       |  8 +--
>  kernel/bpf/verifier.c                         | 38 +++----------
>  .../selftests/bpf/prog_tests/kfunc_call.c     |  2 +
>  .../selftests/bpf/progs/kfunc_call_fail.c     | 12 ++++
>  .../selftests/bpf/progs/kfunc_call_test.c     | 12 ++++
>  .../selftests/bpf/test_kmods/bpf_testmod.c    |  2 +-
>  9 files changed, 72 insertions(+), 65 deletions(-)
> 


Nice to drop those 'is_*_kfunc()' helpers in verifier.

BTW, some of those kfuncs can be dropped from the special_kfunc_list.
That would be better.

Any way, this series looks good to me.

Acked-by: Leon Hwang <leon.hwang@linux.dev>


  parent reply	other threads:[~2026-08-05 16:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 15:33 [PATCH bpf-next v2 0/3] bpf: Allow selected kfuncs under bpf_spin_lock Kaitao Cheng
2026-08-05 15:33 ` [PATCH bpf-next v2 1/3] bpf: Add KF_SPINLOCK_SAFE flag for " Kaitao Cheng
2026-08-05 15:33 ` [PATCH bpf-next v2 2/3] bpf: Mark existing lock-safe kfuncs with KF_SPINLOCK_SAFE Kaitao Cheng
2026-08-05 15:33 ` [PATCH bpf-next v2 3/3] selftests/bpf: Test module kfunc calls under spin lock Kaitao Cheng
2026-08-05 16:51 ` Leon Hwang [this message]
2026-08-06  9:10 ` [PATCH bpf-next v2 0/3] bpf: Allow selected kfuncs under bpf_spin_lock 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=b1825aab-b1d2-40c4-a74c-bb05ce50327d@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@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=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kaitao.cheng@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=shuah@kernel.org \
    --cc=song@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 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.