Skip to content

bpf: fix precision backtracking instruction iteration

Paul Chaignon stable 1 version Applied

Status from this message: Queued for 6.6, thanks.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/10bpf: support non-r10 register spill/fill to/from stack in precision trackinginclude/linux/bpf_verifier.h kernel/bpf/verifier.c tools/testing/selftests/bpf/progs/verifier_subprog_precision.c +1 more+169 -980 replies
2/10selftests/bpf: add stack access precision testtools/testing/selftests/bpf/progs/verifier_subprog_precision.c+59 -50 replies
3/10bpf: preserve STACK_ZERO slots on partial reg spillskernel/bpf/verifier.c+23 -50 replies
4/10selftests/bpf: validate STACK_ZERO is preserved on subreg spilltools/testing/selftests/bpf/progs/verifier_spill_fill.c+40 -00 replies
5/10bpf: preserve constant zero when doing partial register restorekernel/bpf/verifier.c+21 -40 replies
6/10selftests/bpf: validate zero preservation for sub-slot loadstools/testing/selftests/bpf/progs/verifier_spill_fill.c+71 -00 replies
7/10bpf: track aligned STACK_ZERO cases as imprecise spilled registerskernel/bpf/verifier.c+7 -30 replies
8/10selftests/bpf: validate precision logic in partial_stack_load_preserves_zerostools/testing/selftests/bpf/progs/verifier_spill_fill.c+16 -00 replies
9/10bpf: handle fake register spill to stack with BPF_ST_MEM instructionkernel/bpf/verifier.c+0 -10 replies
10/10selftests/bpf: validate fake register spill/fill precision backtracking logictools/testing/selftests/bpf/progs/verifier_spill_fill.c+154 -00 replies

Reviews trailers per patch

All 10 patches have a Reviewed-by or Acked-by.

PatchEduard ZingermanShung-Hsi YuDaniel BorkmannLevi Zim
SeriesT-b
1/10A-b A-b A-b
2/10A-b A-b A-b
3/10A-b A-b A-b
4/10A-b A-b A-b
5/10A-b A-b A-b
6/10A-b A-b
7/10A-b A-b A-b
8/10A-b A-b A-b
9/10A-b A-b A-b
10/10A-b A-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 6.6.y 00/10] bpf: fix precision backtracking instruction iteration

The first patch in this patchset was already backported before, as commit ecc2aeeaa08a, to address CVE-2023-52920 [1]. That backport was however later reverted in commit 199f04528737 because it reduced the efficiency of the BPF verifier, to the point that it rejected some previously-accepted programs.

This patchset backports commit 41f6f64e6999 ("bpf: support non-r10 register spill/fill to/from stack in precision tracking") again, but this time with the subsequent commits that improved the efficiency of the verifier. In addition, the last two commits fix and test a regression that was later found in commit 41f6f64e6999.

It took us a while with Shung-Hsi to come back to this because we felt we didn't have enough test coverage to backport this. That changed with the stable BPF CI Shung-Hsi built for v6.6, which successfully validated this patchset [2]. In addition, I tested the impact of this patchset on the verifier's efficiency with Cilium's BPF programs [3]:
it significantly improves, reducing the number of instructions the verifier has to analyze by up to 87% in some cases!

1: https://lore.kernel.org/linux-cve-announce/2024110518-CVE-2023-52920-17f6@gregkh/
2: https://github.com/pchaigno/stable-bpf-ci/actions/runs/25671397661/job/75357317078
3: https://pchaigno.github.io/test-verifier-complexity.html

Andrii Nakryiko (10):
bpf: support non-r10 register spill/fill to/from stack in precision
tracking
selftests/bpf: add stack access precision test
bpf: preserve STACK_ZERO slots on partial reg spills selftests/bpf: validate STACK_ZERO is preserved on subreg spill
bpf: preserve constant zero when doing partial register restore selftests/bpf: validate zero preservation for sub-slot loads
bpf: track aligned STACK_ZERO cases as imprecise spilled registers selftests/bpf: validate precision logic in
partial_stack_load_preserves_zeros
bpf: handle fake register spill to stack with BPF_ST_MEM instruction selftests/bpf: validate fake register spill/fill precision
backtracking logic

 include/linux/bpf_verifier.h                  |  31 +-
 kernel/bpf/verifier.c                         | 233 +++++++++------
 .../selftests/bpf/progs/verifier_spill_fill.c | 281 ++++++++++++++++++
 .../bpf/progs/verifier_subprog_precision.c    |  87 +++++-
 .../testing/selftests/bpf/verifier/precise.c  |  38 ++-
 5 files changed, 557 insertions(+), 113 deletions(-)
Signature · 1 line
2.43.0