]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: Find eligible subprogs for private stack support
authorYonghong Song <yonghong.song@linux.dev>
Tue, 12 Nov 2024 16:39:07 +0000 (08:39 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 13 Nov 2024 00:26:24 +0000 (16:26 -0800)
commita76ab5731e32d50ff5b1ae97e9dc4b23f41c23f5
treea104cbc12ec9710639d696b294712b98468ab153
parentc748a255aedfd42adc4213479f669f0f4809b85e
bpf: Find eligible subprogs for private stack support

Private stack will be allocated with percpu allocator in jit time.
To avoid complexity at runtime, only one copy of private stack is
available per cpu per prog. So runtime recursion check is necessary
to avoid stack corruption.

Current private stack only supports kprobe/perf_event/tp/raw_tp
which has recursion check in the kernel, and prog types that use
bpf trampoline recursion check. For trampoline related prog types,
currently only tracing progs have recursion checking.

To avoid complexity, all async_cb subprogs use normal kernel stack
including those subprogs used by both main prog subtree and async_cb
subtree. Any prog having tail call also uses kernel stack.

To avoid jit penalty with private stack support, a subprog stack
size threshold is set such that only if the stack size is no less
than the threshold, private stack is supported. The current threshold
is 64 bytes. This avoids jit penality if the stack usage is small.

A useless 'continue' is also removed from a loop in func
check_max_stack_depth().

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20241112163907.2223839-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_verifier.h
include/linux/filter.h
kernel/bpf/core.c
kernel/bpf/verifier.c