From: Yonghong Song <yonghong.song@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
eddyz87@gmail.com, kernel-team@fb.com, martin.lau@kernel.org,
mason@kernel.org, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2 05/20] bpf: Make exception landing pads reachable in the CFG
Date: Sat, 19 Sep 2026 12:32:17 -0700 [thread overview]
Message-ID: <bd29b455-dce5-4708-8fe7-e8baf437ed66@linux.dev> (raw)
In-Reply-To: <f6f9de46294b24824fb67c5246d73bc720391d52e5dd4cf36af398a215fbb414@mail.kernel.org>
On 9/17/26 10:44 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/kernel/bpf/liveness.c b/kernel/bpf/liveness.c
>> index 44ecdc5b4ec2d..9cfd05f970bc9 100644
>> --- a/kernel/bpf/liveness.c
>> +++ b/kernel/bpf/liveness.c
>> @@ -8,6 +8,8 @@
>> #include <linux/slab.h>
>> #include <linux/sort.h>
>>
>> +#include "exception.h"
>> +
>> #define verbose(env, fmt, args...) bpf_verifier_log_write(env, fmt, ##args)
>>
>> struct per_frame_masks {
>> @@ -256,6 +258,9 @@ bpf_insn_successors(struct bpf_verifier_env *env, u32 idx)
>> succ = env->succ;
>> succ->cnt = 0;
>>
>> + if (unlikely(bpf_is_unwind_resume_kfunc(insn)))
>> + return succ;
>> +
> Should this early return be gated on env->cleanup_info_cnt?
>
> bpf_unwind_resume() is an unconditionally registered generic kfunc with no
> KF_ flag restricting it to programs that carry a cleanup table. Its body
> is empty, so at run time the call simply returns and execution continues
> at the next instruction.
This should be okay without env->cleanup_info_cnt guard. Eventually if
bpf_unwind_resume() is not in cleanup region, a verifier error message
will be in the log.
>
> visit_insn() in cfg.c still gives the call a fallthrough edge, and at this
> commit nothing in do_check() rejects a bpf_unwind_resume() call that is not
> the tail of a cleanup landing pad. So any CAP_BPF program with no cleanup
> table can call bpf_unwind_resume() and keep executing after it.
>
> For such a program, bpf_insn_successors() reports zero successors, so
> bpf_compute_live_registers() treats everything after the call as dead. The
> register-cleaning side fails closed (a poisoned slot is rejected), but the
> 32-bit zero-extension side fails open:
>
> insn_aux[i].zext_dst for an insn preceding the call is only set when the
> hi half of the defined register is live-after, so it stays false, and
> bpf_opt_subreg_zext_lo32_rnd_hi32() (kernel/bpf/fixups.c:706) then does
> 'if (!aux[adj_idx].zext_dst) { if (!rnd_hi32) continue; ... }' and emits
> no BPF_ZEXT_REG.
>
> On architectures where bpf_jit_needs_zext() is true and kfunc calls are
> supported (s390, riscv64, powerpc64, parisc, x86-32), the upper 32 bits of
> a register the verifier proved to be 32-bit bounded are left with stale
> JIT-defined contents, which defeats the range checks the verifier derived
> for it.
>
> Compare with the pad lookup ten lines below:
>
>> opcode_info = &opcode_info_tbl[BPF_CLASS(insn->code) | BPF_OP(insn->code)];
>> insn_sz = bpf_is_ldimm64(insn) ? 2 : 1;
>> if (opcode_info->can_fallthrough)
>> @@ -264,6 +269,13 @@ bpf_insn_successors(struct bpf_verifier_env *env, u32 idx)
>> if (opcode_info->can_jump)
>> succ->items[succ->cnt++] = idx + bpf_jmp_offset(insn) + 1;
>>
>> + if (unlikely(env->cleanup_info_cnt)) {
>> + int pad = bpf_cleanup_pad_of_call(env, idx);
>> +
>> + if (pad >= 0)
>> + succ->items[succ->cnt++] = pad;
>> + }
> which gates the pad lookup on cleanup_info_cnt, and with
> visit_cleanup_pad_edge() in kernel/bpf/cfg.c which returns DONE_EXPLORING
> when !env->cleanup_info_cnt.
>
> Would gating the early return on env->cleanup_info_cnt fix this? That
> would be sound because a program that carries a cleanup table is
> additionally constrained (bpf_jit_supports_cleanup_pads() plus, from commit
> fa6890df61539 onward, the requirement that a resume sit at the end of a
> landing pad), whereas a program with cleanup_info_cnt == 0 must keep the
> ordinary fallthrough successor of the call.
As I mentioned, previous gating with "env->cleanup_info_cnt" is not
necessary.
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35308528711
next prev parent reply other threads:[~2026-09-19 19:32 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 4:41 [PATCH bpf-next v2 00/20] bpf: Run exception cleanup landing pads when bpf_throw() unwinds Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 01/20] bpf: Accept the compiler's exception cleanup table at program load Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 02/20] bpf: Add the bpf_unwind_resume() kfunc Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 03/20] bpf: Add lookups for exception cleanup resumes and landing pads Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 4:55 ` Alexei Starovoitov
2026-09-19 17:42 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 04/20] bpf: Mark the call sites an exception cleanup table covers Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 05/20] bpf: Make exception landing pads reachable in the CFG Yonghong Song
2026-09-18 4:59 ` sashiko-bot
2026-09-19 19:17 ` Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 19:32 ` Yonghong Song [this message]
2026-09-18 4:42 ` [PATCH bpf-next v2 06/20] bpf: Explore the landing pads no call site reaches Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 19:32 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 07/20] bpf: Refuse exception cleanup shapes bpf_throw() cannot dispatch Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 08/20] bpf: Walk the exception unwind in the verifier Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 09/20] bpf: Refuse a private stack for a program with an exception cleanup table Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 19:37 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 10/20] bpf: Dispatch exception cleanup pads from bpf_throw() Yonghong Song
2026-09-18 5:58 ` bot+bpf-ci
2026-09-19 19:54 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 11/20] bpf, x86: Dispatch exception cleanup pads at run time Yonghong Song
2026-09-18 5:03 ` sashiko-bot
2026-09-19 20:00 ` Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 20:04 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 12/20] bpf, arm64: " Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 20:07 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 13/20] libbpf: Resolve the compiler's _Unwind_Resume to the kernel's kfunc Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 14/20] libbpf: Add cleanup_info to bpf_prog_load_opts Yonghong Song
2026-09-18 4:57 ` sashiko-bot
2026-09-19 20:18 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 15/20] libbpf: Collect .bpf_cleanup records and pass them to the kernel Yonghong Song
2026-09-18 5:00 ` sashiko-bot
2026-09-19 20:21 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 16/20] libbpf: Carry the exception cleanup table through the light skeleton Yonghong Song
2026-09-18 5:02 ` sashiko-bot
2026-09-19 20:27 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 17/20] libbpf: Let the static linker carry .bpf_cleanup relocations Yonghong Song
2026-09-18 5:01 ` sashiko-bot
2026-09-19 20:31 ` Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 20:32 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 18/20] selftests/bpf: Add an end-to-end .bpf_cleanup exception test Yonghong Song
2026-09-18 4:59 ` sashiko-bot
2026-09-18 5:58 ` bot+bpf-ci
2026-09-19 20:34 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 19/20] selftests/bpf: Cover the exception cleanup shapes the chain does not reach Yonghong Song
2026-09-18 5:01 ` sashiko-bot
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 21:13 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 20/20] selftests/bpf: Load an exception cleanup program from a light skeleton Yonghong Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bd29b455-dce5-4708-8fe7-e8baf437ed66@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.