BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 1/2] bpf: allow terminal gotox instructions
@ 2026-08-31 22:33 Siddharth Chintamaneni
  2026-08-31 22:33 ` [PATCH bpf-next v2 2/2] selftests/bpf: Test " Siddharth Chintamaneni
  2026-08-31 23:26 ` [PATCH bpf-next v2 1/2] bpf: allow " bot+bpf-ci
  0 siblings, 2 replies; 7+ messages in thread
From: Siddharth Chintamaneni @ 2026-08-31 22:33 UTC (permalink / raw)
  To: bpf
  Cc: Siddharth Chintamaneni, Anton Protopopov, Alexei Starovoitov,
	Daniel Borkmann, John Fastabend, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis,
	Ihor Solodrai, Puranjay Mohan, rlmenge, hargar, apais

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.

Fixes: 493d9e0d6083 ("bpf, x86: add support for indirect jumps")
Signed-off-by: Siddharth Chintamaneni <sidchintamaneni@gmail.com>
Reviewed-by: Anton Protopopov <a.s.protopopov@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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-09-01 16:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 22:33 [PATCH bpf-next v2 1/2] bpf: allow terminal gotox instructions Siddharth Chintamaneni
2026-08-31 22:33 ` [PATCH bpf-next v2 2/2] selftests/bpf: Test " Siddharth Chintamaneni
2026-08-31 23:26   ` bot+bpf-ci
2026-09-01 13:58     ` Anton Protopopov
2026-09-01 16:21       ` Siddharth Chintamaneni
2026-08-31 23:26 ` [PATCH bpf-next v2 1/2] bpf: allow " bot+bpf-ci
2026-09-01 13:51   ` Anton Protopopov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox