Skip to content

Commit d6f1629

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 37cb61a commit d6f1629

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

@@ -17156,9 +17156,8 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
1715617156
}
1715717157

1715817158
if (frame->in_async_callback_fn) {
17159-
/* enforce return zero from async callbacks like timer */
1716017159
exit_ctx = "At async callback return";
17161-
range = retval_range(0, 0);
17160+
range = frame->callback_ret_range;
1716217161
goto enforce_retval;
1716317162
}
1716417163

0 commit comments

Comments
 (0)