]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: Do not allow tail call in strcut_ops program with __ref argument
authorAmery Hung <ameryhung@gmail.com>
Thu, 20 Feb 2025 22:15:31 +0000 (14:15 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 21 Feb 2025 02:44:35 +0000 (18:44 -0800)
commit38f1e66abd184c8f69b8d2c7d1ac02f32943b47b
tree7234c275c6362cfb466608bfcdd6c5988c490319
parente0525cd72b5979d8089fe524a071ea93fd011dc9
bpf: Do not allow tail call in strcut_ops program with __ref argument

Reject struct_ops programs with refcounted kptr arguments (arguments
tagged with __ref suffix) that tail call. Once a refcounted kptr is
passed to a struct_ops program from the kernel, it can be freed or
xchged into maps. As there is no guarantee a callee can get the same
valid refcounted kptr in the ctx, we cannot allow such usage.

Signed-off-by: Amery Hung <ameryhung@gmail.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20250220221532.1079331-1-ameryhung@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c