From: Anton Protopopov <a.s.protopopov@gmail.com>
To: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Puranjay Mohan <puranjay@kernel.org>,
rachelmenge@gmail.com, hargar@microsoft.com, apais@microsoft.com
Subject: Re: [PATCH bpf-next v1 1/2] bpf: allow terminal gotox instructions
Date: Mon, 31 Aug 2026 12:21:24 +0000 [thread overview]
Message-ID: <apVxxDcvCSzlw2FG@mail.gmail.com> (raw)
In-Reply-To: <20260830073125.360934-1-sidchintamaneni@gmail.com>
On 26/08/30 07:31AM, Siddharth Chintamaneni wrote:
> check_subprogs() treats gotox as a direct jump and validates its reserved
> zero offset. When gotox is the final instruction, this produces a
> synthetic successor one instruction past the end of the subprogram and
> rejects an otherwise valid program.
>
> Skip direct-offset validation for gotox and accept it as a
> non-fallthrough terminal instruction. Its actual targets remain validated
> from the instruction-array jump table during CFG construction.
Thanks, the fix looks correct.
I have comments to the selftest, so expecting v2. When you resend it,
please capitalize "allow" in this commit's title.
Reviewed-by: Anton Protopopov <a.s.protopopov@gmail.com>
> Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
> ---
> kernel/bpf/verifier.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index e036ae20bf6b..44195ec1445d 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -3087,6 +3087,8 @@ static int check_subprogs(struct bpf_verifier_env *env)
> subprog[cur_subprog].exit_idx = i;
> goto next;
> }
> + if (insn_is_gotox(&insn[i]))
> + goto next;
> off = i + bpf_jmp_offset(&insn[i]) + 1;
> if (off < subprog_start || off >= subprog_end) {
> verbose(env, "jump out of range from insn %d to %d\n", i, off);
> @@ -3106,7 +3108,8 @@ static int check_subprogs(struct bpf_verifier_env *env)
> */
> if (code != (BPF_JMP | BPF_EXIT) &&
> code != (BPF_JMP32 | BPF_JA) &&
> - code != (BPF_JMP | BPF_JA)) {
> + code != (BPF_JMP | BPF_JA) &&
> + !insn_is_gotox(&insn[i])) {
> verbose(env, "last insn is not an exit or jmp\n");
> bpf_diag_program_structure(
> env, i, "subprogram can fall through",
>
> base-commit: cd35e1b10182c42b4ae31ee49119463b17d8ba7f
> --
> 2.43.0
>
prev parent reply other threads:[~2026-08-31 12:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 7:31 [PATCH bpf-next v1 1/2] bpf: allow terminal gotox instructions Siddharth Chintamaneni
2026-08-30 7:31 ` [PATCH bpf-next v1 2/2] selftests/bpf: Add compiler-layout terminal gotox test Siddharth Chintamaneni
2026-08-31 12:34 ` Anton Protopopov
2026-08-30 7:45 ` [PATCH bpf-next v1 1/2] bpf: allow terminal gotox instructions sashiko-bot
2026-08-30 8:34 ` bot+bpf-ci
2026-08-31 12:21 ` Anton Protopopov [this message]
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=apVxxDcvCSzlw2FG@mail.gmail.com \
--to=a.s.protopopov@gmail.com \
--cc=andrii@kernel.org \
--cc=apais@microsoft.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hargar@microsoft.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=puranjay@kernel.org \
--cc=rachelmenge@gmail.com \
--cc=sidchintamaneni@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox