All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: Fix gotox target validation against CFG
@ 2026-06-09 15:03 Nuoqi Gui
  2026-06-09 15:03 ` [PATCH bpf-next 1/2] " Nuoqi Gui
  2026-06-09 15:03 ` [PATCH bpf-next 2/2] selftests/bpf: Add cross-subprog gotox target coverage Nuoqi Gui
  0 siblings, 2 replies; 10+ messages in thread
From: Nuoqi Gui @ 2026-06-09 15:03 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Anton Protopopov, Shuah Khan, linux-kselftest,
	linux-kernel, Nuoqi Gui

For gotox, CFG construction models the indirect-jump target set in
insn_aux_data->jt, but do_check() later follows targets from the runtime
PTR_TO_INSN register's own INSN_ARRAY map. If the same gotox can be
reached with PTR_TO_INSN values from different maps, do_check() can accept
a target that CFG did not model.

On x86, that can transfer control into another subprog without a matching
BPF call frame and crash when the program is run.

Fix this by rejecting gotox map targets that are absent from the CFG jump
table built for that instruction. Add a regression test covering the
two-map cross-subprog case.

Validation:

  unpatched bpf-next b9452b594fd3:
    F01_02_LOAD_FD=5 errno=0 (accepted)
    SELFTEST F01-02 gotox-cross-subprog: FAIL

  patched bpf-next b9452b594fd3 + this series:
    F01_02_LOAD_FD=-1 errno=22 (Invalid argument)
    gotox target 14 from map id=2 is not in the CFG jump table
    SELFTEST F01-02 gotox-cross-subprog: PASS

Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>
---
Nuoqi Gui (2):
      bpf: Fix gotox target validation against CFG
      selftests/bpf: Add cross-subprog gotox target coverage

 kernel/bpf/verifier.c                              | 26 ++++++++
 tools/testing/selftests/bpf/prog_tests/bpf_gotox.c | 73 ++++++++++++++++++++++
 2 files changed, 99 insertions(+)
---
base-commit: b9452b594fd3aecbfd4aa0a6a1f741330a37dab7
change-id: 20260609-f01-02-gotox-bpf-next-272e6276085d

Best regards,
--  
Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>


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

end of thread, other threads:[~2026-06-09 17:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 15:03 [PATCH bpf-next 0/2] bpf: Fix gotox target validation against CFG Nuoqi Gui
2026-06-09 15:03 ` [PATCH bpf-next 1/2] " Nuoqi Gui
2026-06-09 15:13   ` sashiko-bot
2026-06-09 15:42   ` bot+bpf-ci
2026-06-09 15:56   ` Anton Protopopov
2026-06-09 17:27     ` Eduard Zingerman
2026-06-09 15:03 ` [PATCH bpf-next 2/2] selftests/bpf: Add cross-subprog gotox target coverage Nuoqi Gui
2026-06-09 15:40   ` sashiko-bot
2026-06-09 15:42   ` bot+bpf-ci
2026-06-09 16:14   ` Anton Protopopov

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.