Skip to content

Commit 2ab256e

Browse files
Benjamin TissoiresAlexei Starovoitov
authored andcommitted
bpf: add is_async_callback_calling_insn() helper
Currently we have a special case for BPF_FUNC_timer_set_callback, let's introduce a helper we can extend for the kfunc that will come in a later patch Signed-off-by: Benjamin Tissoires <bentiss@kernel.org> Link: https://lore.kernel.org/r/20240221-hid-bpf-sleepable-v3-3-1fb378ca6301@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent dfe6625 commit 2ab256e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

kernel/bpf/verifier.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,11 @@ static bool is_sync_callback_calling_insn(struct bpf_insn *insn)
528528
(bpf_pseudo_kfunc_call(insn) && is_sync_callback_calling_kfunc(insn->imm));
529529
}
530530

531+
static bool is_async_callback_calling_insn(struct bpf_insn *insn)
532+
{
533+
return bpf_helper_call(insn) && is_async_callback_calling_function(insn->imm);
534+
}
535+
531536
static bool is_storage_get_function(enum bpf_func_id func_id)
532537
{
533538
return func_id == BPF_FUNC_sk_storage_get ||
@@ -9445,9 +9450,7 @@ static int push_callback_call(struct bpf_verifier_env *env, struct bpf_insn *ins
94459450
return -EFAULT;
94469451
}
94479452

9448-
if (insn->code == (BPF_JMP | BPF_CALL) &&
9449-
insn->src_reg == 0 &&
9450-
insn->imm == BPF_FUNC_timer_set_callback) {
9453+
if (is_async_callback_calling_insn(insn)) {
94519454
struct bpf_verifier_state *async_cb;
94529455

94539456
/* there is no real recursion here. timer callbacks are async */
@@ -15588,7 +15591,7 @@ static int visit_insn(int t, struct bpf_verifier_env *env)
1558815591
return DONE_EXPLORING;
1558915592

1559015593
case BPF_CALL:
15591-
if (insn->src_reg == 0 && insn->imm == BPF_FUNC_timer_set_callback)
15594+
if (is_async_callback_calling_insn(insn))
1559215595
/* Mark this call insn as a prune point to trigger
1559315596
* is_state_visited() check before call itself is
1559415597
* processed by __check_func_call(). Otherwise new

0 commit comments

Comments
 (0)