Skip to content

bpf: Fix unsound scalar forking for BPF_OR

Daniel Wade bpf 4 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 0 repliesApplied 2/2
  2. v32 patches 5 repliesSuperseded
  3. v22 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v12 patches4 repliesSuperseded

Patches in v4 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Fix unsound scalar forking in maybe_fork_scalars() for BPF_ORkernel/bpf/verifier.c+1 -10 repliesApplied
2/2selftests/bpf: Add tests for maybe_fork_scalars() OR vs AND handlingtools/testing/selftests/bpf/progs/verifier_bounds.c+94 -00 repliesApplied

Reviews trailers per patch

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

PatchAmery HungEduard Zingerman
1/2R-b A-b
2/2R-b A-b

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

Read the v4 thread

Cover letter [PATCH bpf v4 0/2] bpf: Fix unsound scalar forking for BPF_OR

maybe_fork_scalars() unconditionally sets the pushed path dst register to 0 for both BPF_AND and BPF_OR. For AND this is correct (0 & K == 0), but for OR it is wrong (0 | K == K, not 0). This causes the verifier to track an incorrect value on the pushed path, leading to a verifier/runtime divergence that allows out-of-bounds map value access.

v4: Use block comment style for multi-line comments in selftests (Amery Hung)
Add Reviewed-by/Acked-by tags
v3: Use single-line comment style in selftests (Alexei Starovoitov)
v2: Use push_stack(env, env->insn_idx, ...) to re-execute the insn
on the pushed path (Eduard Zingerman)

Daniel Wade (2):
bpf: Fix unsound scalar forking in maybe_fork_scalars() for BPF_OR selftests/bpf: Add tests for maybe_fork_scalars() OR vs AND handling

 kernel/bpf/verifier.c                         |  2 +-
 .../selftests/bpf/progs/verifier_bounds.c     | 94 +++++++++++++++++++
 2 files changed, 95 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0