Skip to content

Commit 3b8a2b0

Browse files
mykyta5Kernel Patches Daemon
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]>
1 parent d7fa85b commit 3b8a2b0

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
@@ -10867,7 +10867,7 @@ static int set_timer_callback_state(struct bpf_verifier_env *env,
1086710867
__mark_reg_not_init(env, &callee->regs[BPF_REG_4]);
1086810868
__mark_reg_not_init(env, &callee->regs[BPF_REG_5]);
1086910869
callee->in_async_callback_fn = true;
10870-
callee->callback_ret_range = retval_range(0, 1);
10870+
callee->callback_ret_range = retval_range(0, 0);
1087110871
return 0;
1087210872
}
1087310873

@@ -17152,9 +17152,8 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
1715217152
}
1715317153

1715417154
if (frame->in_async_callback_fn) {
17155-
/* enforce return zero from async callbacks like timer */
1715617155
exit_ctx = "At async callback return";
17157-
range = retval_range(0, 0);
17156+
range = frame->callback_ret_range;
1715817157
goto enforce_retval;
1715917158
}
1716017159

0 commit comments

Comments
 (0)