From: Mike Bazov A struct_ops program gets a private stack only if the subsystem requests one, and then its trampoline runs it with a recursion check, so two runs of it on one CPU never share the stack. A tail call enters the program past the trampoline. The caller is a struct_ops program of the same op and has no private stack, since a program with a tail call gets none, so it has no recursion check: two tasks on one CPU can be inside it and both tail-call into the target, which then runs twice on the same private stack. Refuse a struct_ops program that uses a private stack as a prog array element. Fixes: 5bd36da1e37e ("bpf: Support private stack for struct_ops progs") Suggested-by: Alexei Starovoitov Signed-off-by: Mike Bazov --- kernel/bpf/arraymap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 508706d0c36..564a736275a 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c @@ -1044,6 +1044,7 @@ static void *prog_fd_array_get_ptr(struct bpf_map *map, return prog; if (prog->type == BPF_PROG_TYPE_EXT || + (prog->type == BPF_PROG_TYPE_STRUCT_OPS && prog->aux->jits_use_priv_stack) || !bpf_prog_map_compatible(map, prog)) { bpf_prog_put(prog); return ERR_PTR(-EINVAL); -- 2.43.0