An exception cleanup needs two terminators: - bpf_unwind() begins an unwind: the frames it leaves run their landing pads on the way out to the program's exit. It is separate from bpf_throw(), which discards the frames in between. - bpf_unwind_resume() ends a landing pad, carrying the unwind on. The compiler calls it _Unwind_Resume, which a later libbpf patch resolves to this name, and passes it the exception object, which the kfunc takes as ptr__ign. Neither is registered yet: that waits for the patch that dispatches pads at run time. Signed-off-by: Yonghong Song --- kernel/bpf/helpers.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index a284f20c97d5..4eccd6742eba 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -3424,6 +3424,10 @@ static bool bpf_stack_walker(void *cookie, u64 ip, u64 sp, u64 bp) return false; } +__bpf_kfunc void bpf_unwind(void) +{ +} + __bpf_kfunc void bpf_throw(u64 cookie) { struct bpf_throw_ctx ctx = {}; @@ -3445,6 +3449,16 @@ __bpf_kfunc void bpf_throw(u64 cookie) WARN(1, "A call to BPF exception callback should never return\n"); } +__bpf_kfunc void bpf_unwind_resume(void *ptr__ign) +{ + /* + * Never reached: the verifier accepts this kfunc only as a frame + * terminator and bpf_do_misc_fixups() lowers every one of them to + * 'r0 = 0; exit', so no call to this body survives to run. + */ + WARN_ONCE(1, "exception cleanup resume was not lowered to a return\n"); +} + __bpf_kfunc int bpf_wq_init(struct bpf_wq *wq, void *p__const_map, unsigned int flags) { struct bpf_async_kern *async = (struct bpf_async_kern *)wq; -- 2.53.0-Meta