Skip to content

Misc BPF gotox fixes

Daniel Borkmann bpf 3 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest16 patches 1 replyApplied 16/16
  2. v211 patches 9 repliesSuperseded
  3. v16 patches 11 repliesSuperseded

Changes in v3 from the cover letter

- Rebased onto bpf-next given indirect call series landed
- Split out the exit_idx sentinel as its own fix (Eduard)
- Return early from visit_gotox_insn() on a revisited gotox (Eduard)
- Check both ends of the target slice in check_indirect_jump() (Eduard)
- Rewrite edge limit and nop target tests in inline asm (Eduard)
- Name the patch modes BPF_PATCH_{KEEP,MOVE}_TARGET (Eduard)
- Drop the insn array stale reuse test (Eduard)
- Clear the insn array used flag with release semantics (sashiko)
- Add fix for the exception callback index after dead subprog removal
- Free the jump tables of removed subprogs and on a failed table build
- Shift the poke descriptors along with the insn array slots

Patches in v3 All 16 applied

#Subject and filesSizeRepliesApplied
1/16bpf: Avoid quadratic successor rescan in bpf_compute_scckernel/bpf/cfg.c+20 -60 repliesApplied
2/16bpf: Bound the number of indirect jump edges in a programinclude/linux/bpf_verifier.h kernel/bpf/cfg.c+16 -00 repliesApplied
3/16bpf: Rebase the exception callback subprog when dead subprogs are removedkernel/bpf/fixups.c+3 -00 repliesApplied
4/16bpf: Leave out the hidden exit edge of a subprogram without an exitinclude/linux/bpf_verifier.h kernel/bpf/cfg.c kernel/bpf/verifier.c+13 -40 repliesApplied
5/16bpf: Cache the jump table of a subprogram during CFG discoveryinclude/linux/bpf_verifier.h kernel/bpf/cfg.c kernel/bpf/fixups.c +2 more+134 -1201 replyApplied
6/16bpf: Reject indirect jumps that leave their subprogramkernel/bpf/cfg.c kernel/bpf/verifier.c tools/testing/selftests/bpf/progs/verifier_gotox.c+51 -360 repliesApplied
7/16bpf: Don't remove indirect jump targets in the nop removal passkernel/bpf/fixups.c+3 -00 repliesApplied
8/16bpf: Clear insn array jitted pointers on map reusekernel/bpf/bpf_insn_array.c+8 -40 repliesApplied
9/16bpf: Clear the insn array used flag with release semanticskernel/bpf/bpf_insn_array.c+2 -10 repliesApplied
10/16bpf: Retarget indirect jump targets across prologue prependsinclude/linux/bpf.h kernel/bpf/bpf_insn_array.c kernel/bpf/fixups.c+43 -190 repliesApplied
11/16selftests/bpf: Add tests for the indirect jump edge limittools/testing/selftests/bpf/progs/verifier_gotox.c+94 -00 repliesApplied
12/16selftests/bpf: Add a test for a tail call in a subprogram without an exittools/testing/selftests/bpf/progs/verifier_cfg.c+38 -00 repliesApplied
13/16selftests/bpf: Add tests for indirect jumps across subprogramstools/testing/selftests/bpf/prog_tests/bpf_insn_array.c+541 -00 repliesApplied
14/16selftests/bpf: Add a test for gotox nop targetstools/testing/selftests/bpf/progs/verifier_gotox.c+29 -00 repliesApplied
15/16selftests/bpf: Add tests for gotox targets across prologue prependstools/testing/selftests/bpf/prog_tests/bpf_insn_array.c+108 -190 repliesApplied
16/16selftests/bpf: Add a test for an exception callback behind a dead subprogtools/testing/selftests/bpf/prog_tests/exceptions.c tools/testing/selftests/bpf/progs/exceptions_dead_subprog.c+47 -00 repliesApplied

Reviews trailers per patch

7 of 16 patches have a Reviewed-by or Acked-by.

PatchEduard ZingermanAnton Protopopov
1/16A-b
2/16A-b
3/16
4/16
5/16
6/16A-b A-b
7/16A-b A-b
8/16A-b A-b
9/16
10/16A-b A-b
11/16
12/16
13/16
14/16
15/16A-b
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH bpf-next v3 00/16] Misc BPF gotox fixes

Address various open issues around gotox instruction, see individual commits for details. Also BPF selftests are added to assert that these are addressed.

v2 -> v3:
- Rebased onto bpf-next given indirect call series landed
- Split out the exit_idx sentinel as its own fix (Eduard)
- Return early from visit_gotox_insn() on a revisited gotox (Eduard)
- Check both ends of the target slice in check_indirect_jump() (Eduard)
- Rewrite edge limit and nop target tests in inline asm (Eduard)
- Name the patch modes BPF_PATCH_{KEEP,MOVE}_TARGET (Eduard)
- Drop the insn array stale reuse test (Eduard)
- Clear the insn array used flag with release semantics (sashiko)
- Add fix for the exception callback index after dead subprog removal
- Free the jump tables of removed subprogs and on a failed table build
- Shift the poke descriptors along with the insn array slots
v1 -> v2:
- Remove jt_spans_subprogs and reject right away (Eduard)
- Rework jump table to no longer keep it in insn_aux_data (Eduard)
- Fix up comments in bpf_compute_scc (Eduard)
- Fix up commit message nit wrt signed_loader (Anton)
- Added 3 more fixes related to gotox along with BPF selftests

Daniel Borkmann (16):
bpf: Avoid quadratic successor rescan in bpf_compute_scc
bpf: Bound the number of indirect jump edges in a program
bpf: Rebase the exception callback subprog when dead subprogs are removed
bpf: Leave out the hidden exit edge of a subprogram without an exit
bpf: Cache the jump table of a subprogram during CFG discovery
bpf: Reject indirect jumps that leave their subprogram
bpf: Don't remove indirect jump targets in the nop removal pass
bpf: Clear insn array jitted pointers on map reuse
bpf: Clear the insn array used flag with release semantics
bpf: Retarget indirect jump targets across prologue prepends selftests/bpf: Add tests for the indirect jump edge limit selftests/bpf: Add a test for a tail call in a subprogram without an exit selftests/bpf: Add tests for indirect jumps across subprograms selftests/bpf: Add a test for gotox nop targets selftests/bpf: Add tests for gotox targets across prologue prepends selftests/bpf: Add a test for an exception callback behind a dead subprog

 include/linux/bpf.h                           |   2 +-
 include/linux/bpf_verifier.h                  |  12 +-
 kernel/bpf/bpf_insn_array.c                   |  19 +-
 kernel/bpf/cfg.c                              | 241 ++++---
 kernel/bpf/fixups.c                           |  92 ++-
 kernel/bpf/liveness.c                         |  26 +-
 kernel/bpf/verifier.c                         |  37 +-
 .../selftests/bpf/prog_tests/bpf_insn_array.c | 650 +++++++++++++++++-
 .../selftests/bpf/prog_tests/exceptions.c     |   7 +
 .../bpf/progs/exceptions_dead_subprog.c       |  40 ++
 .../selftests/bpf/progs/verifier_cfg.c        |  38 +
 .../selftests/bpf/progs/verifier_gotox.c      | 125 +++-
 12 files changed, 1115 insertions(+), 174 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/exceptions_dead_subprog.c
Signature · 1 line
2.43.0