From: Mykyta Yatsenko introducing bpf timer cancel kfunc that attempts canceling timer asynchronously, hence, supports working in NMI context. Signed-off-by: Mykyta Yatsenko --- kernel/bpf/helpers.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 297723d3f146a6e2f2e3e2dbf249506ae35bf3a2..2acab81599b6d9f4dc6c5ba636b9f9bd46be9d81 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -4425,6 +4425,18 @@ __bpf_kfunc int bpf_dynptr_file_discard(struct bpf_dynptr *dynptr) return 0; } +__bpf_kfunc int bpf_timer_cancel_async(struct bpf_timer *timer) +{ + struct bpf_async_cb *cb; + struct bpf_async_kern *async = (void *)timer; + + cb = READ_ONCE(async->cb); + if (!cb) + return -EINVAL; + + return bpf_async_schedule_op(cb, BPF_ASYNC_CANCEL, 0, 0); +} + __bpf_kfunc_end_defs(); static void bpf_task_work_cancel_scheduled(struct irq_work *irq_work) @@ -4606,6 +4618,7 @@ BTF_ID_FLAGS(func, bpf_task_work_schedule_signal_impl) BTF_ID_FLAGS(func, bpf_task_work_schedule_resume_impl) BTF_ID_FLAGS(func, bpf_dynptr_from_file) BTF_ID_FLAGS(func, bpf_dynptr_file_discard) +BTF_ID_FLAGS(func, bpf_timer_cancel_async) BTF_KFUNCS_END(common_btf_ids) static const struct btf_kfunc_id_set common_kfunc_set = { -- 2.52.0