Skip to content

Commit 7645629

Browse files
Sebastian Andrzej Siewiorborkmann
authored andcommitted
bpf: Invoke __bpf_prog_exit_sleepable_recur() on recursion in kern_sys_bpf().
If __bpf_prog_enter_sleepable_recur() detects recursion then it returns 0 without undoing rcu_read_lock_trace(), migrate_disable() or decrementing the recursion counter. This is fine in the JIT case because the JIT code will jump in the 0 case to the end and invoke the matching exit trampoline (__bpf_prog_exit_sleepable_recur()). This is not the case in kern_sys_bpf() which returns directly to the caller with an error code. Add __bpf_prog_exit_sleepable_recur() as clean up in the recursion case. Fixes: b1d18a7 ("bpf: Extend sys_bpf commands for bpf_syscall programs.") Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a454d84 commit 7645629

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/bpf/syscall.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5505,6 +5505,7 @@ int kern_sys_bpf(int cmd, union bpf_attr *attr, unsigned int size)
55055505
run_ctx.saved_run_ctx = NULL;
55065506
if (!__bpf_prog_enter_sleepable_recur(prog, &run_ctx)) {
55075507
/* recursion detected */
5508+
__bpf_prog_exit_sleepable_recur(prog, 0, &run_ctx);
55085509
bpf_prog_put(prog);
55095510
return -EBUSY;
55105511
}

0 commit comments

Comments
 (0)