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>
This commit is contained in:
parent
dfe6625df4
commit
2ab256e932
1 changed files with 7 additions and 4 deletions
|
@ -528,6 +528,11 @@ static bool is_sync_callback_calling_insn(struct bpf_insn *insn)
|
||||||
(bpf_pseudo_kfunc_call(insn) && is_sync_callback_calling_kfunc(insn->imm));
|
(bpf_pseudo_kfunc_call(insn) && is_sync_callback_calling_kfunc(insn->imm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_async_callback_calling_insn(struct bpf_insn *insn)
|
||||||
|
{
|
||||||
|
return bpf_helper_call(insn) && is_async_callback_calling_function(insn->imm);
|
||||||
|
}
|
||||||
|
|
||||||
static bool is_storage_get_function(enum bpf_func_id func_id)
|
static bool is_storage_get_function(enum bpf_func_id func_id)
|
||||||
{
|
{
|
||||||
return func_id == BPF_FUNC_sk_storage_get ||
|
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
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insn->code == (BPF_JMP | BPF_CALL) &&
|
if (is_async_callback_calling_insn(insn)) {
|
||||||
insn->src_reg == 0 &&
|
|
||||||
insn->imm == BPF_FUNC_timer_set_callback) {
|
|
||||||
struct bpf_verifier_state *async_cb;
|
struct bpf_verifier_state *async_cb;
|
||||||
|
|
||||||
/* there is no real recursion here. timer callbacks are async */
|
/* 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)
|
||||||
return DONE_EXPLORING;
|
return DONE_EXPLORING;
|
||||||
|
|
||||||
case BPF_CALL:
|
case BPF_CALL:
|
||||||
if (insn->src_reg == 0 && insn->imm == BPF_FUNC_timer_set_callback)
|
if (is_async_callback_calling_insn(insn))
|
||||||
/* Mark this call insn as a prune point to trigger
|
/* Mark this call insn as a prune point to trigger
|
||||||
* is_state_visited() check before call itself is
|
* is_state_visited() check before call itself is
|
||||||
* processed by __check_func_call(). Otherwise new
|
* processed by __check_func_call(). Otherwise new
|
||||||
|
|
Loading…
Add table
Reference in a new issue