Skip to content

Commit d2699bd

Browse files
mykyta5Alexei Starovoitov
authored andcommitted
bpf: verifier: permit non-zero returns from async callbacks
The verifier currently enforces a zero return value for all async callbacks—a constraint originally introduced for bpf_timer. That restriction is too narrow for other async use cases. Relax the rule by allowing non-zero return codes from async callbacks in general, while preserving the zero-return requirement for bpf_timer to maintain its existing semantics. Signed-off-by: Mykyta Yatsenko <[email protected]> Acked-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent acc3a0d commit d2699bd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

kernel/bpf/verifier.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10789,7 +10789,7 @@ static int set_timer_callback_state(struct bpf_verifier_env *env,
1078910789
__mark_reg_not_init(env, &callee->regs[BPF_REG_4]);
1079010790
__mark_reg_not_init(env, &callee->regs[BPF_REG_5]);
1079110791
callee->in_async_callback_fn = true;
10792-
callee->callback_ret_range = retval_range(0, 1);
10792+
callee->callback_ret_range = retval_range(0, 0);
1079310793
return 0;
1079410794
}
1079510795

@@ -17073,9 +17073,8 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
1707317073
}
1707417074

1707517075
if (frame->in_async_callback_fn) {
17076-
/* enforce return zero from async callbacks like timer */
1707717076
exit_ctx = "At async callback return";
17078-
range = retval_range(0, 0);
17077+
range = frame->callback_ret_range;
1707917078
goto enforce_retval;
1708017079
}
1708117080

0 commit comments

Comments
 (0)