mbox series

[v2,0/2] bpf: Allow bpf_for/bpf_repeat while holding spin

Message ID 20250104202528.882482-1-emil@etsalapatis.com (mailing list archive)
Headers show
Series bpf: Allow bpf_for/bpf_repeat while holding spin | expand

Message

Emil Tsalapatis Jan. 4, 2025, 8:25 p.m. UTC
From: Emil Tsalapatis (Meta) <emil@etsalapatis.com>

In BPF programs, kfunc calls while holding a lock are not allowed
because kfuncs may sleep by default. The exception to this rule are the
functions in special_kfunc_list, which are guaranteed to not sleep. The
bpf_iter_num_* functions used by the bpf_for and bpf_repeat macros make
no function calls themselves, and as such are guaranteed to not sleep.
Add them to special_kfunc_list to allow them within BPF spinlock
critical sections.

Signed-off-by: Emil Tsalapatis (Meta) <emil@etsalapatis.com>

Emil Tsalapatis (2):
  bpf: Allow bpf_for/bpf_repeat calls while holding a spinlock
  selftests/bpf: test bpf_for within spin lock section

 kernel/bpf/verifier.c                         | 20 +++++++++++++-
 .../selftests/bpf/progs/verifier_spin_lock.c  | 26 +++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Jan. 6, 2025, 7:10 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sat,  4 Jan 2025 15:25:26 -0500 you wrote:
> From: Emil Tsalapatis (Meta) <emil@etsalapatis.com>
> 
> In BPF programs, kfunc calls while holding a lock are not allowed
> because kfuncs may sleep by default. The exception to this rule are the
> functions in special_kfunc_list, which are guaranteed to not sleep. The
> bpf_iter_num_* functions used by the bpf_for and bpf_repeat macros make
> no function calls themselves, and as such are guaranteed to not sleep.
> Add them to special_kfunc_list to allow them within BPF spinlock
> critical sections.
> 
> [...]

Here is the summary with links:
  - [v2,1/2] bpf: Allow bpf_for/bpf_repeat calls while holding a spinlock
    https://git.kernel.org/bpf/bpf-next/c/512816403ece
  - [v2,2/2] selftests/bpf: test bpf_for within spin lock section
    https://git.kernel.org/bpf/bpf-next/c/87091dd986db

You are awesome, thank you!