Skip to content

bpf: Fix OOB read and add tests for load-acquire/store-release

Kohei Enju bpf lkml 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 Latest2 patches 0 repliesApplied 2/2
  2. v22 patches 4 repliesSuperseded
  3. v11 patch 3 repliesSuperseded

Changes in v3 from the cover letter

- Change invalid register from R11 to R15 in new tests
v2: https://lore.kernel.org/all/[email protected]/
- Just swap atomic_ptr_type_ok() and check_load_mem()/check_store_reg()
- Update some tests that were assuming the previous order of checks
- Add new tests specifically for the invalid register number
v1: https://lore.kernel.org/bpf/[email protected]/

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Fix out-of-bounds read in check_atomic_load/store()kernel/bpf/verifier.c tools/testing/selftests/bpf/progs/verifier_load_acquire.c tools/testing/selftests/bpf/progs/verifier_store_release.c+35 -70 repliesApplied
2/2selftests/bpf: Add selftests for load-acquire/store-release when register number is invalidtools/testing/selftests/bpf/progs/verifier_load_acquire.c tools/testing/selftests/bpf/progs/verifier_store_release.c+28 -00 repliesApplied

Reviews trailers per patch

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

Patch[email protected]Eduard Zingerman
1/2T-b A-b
2/2A-b

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 v3 bpf-next 0/2] bpf: Fix OOB read and add tests for load-acquire/store-release

This patch series addresses an out-of-bounds read issue in check_atomic_load/store() reported by syzkaller when an invalid register number (MAX_BPF_REG or greater) is used.

The first patch fixes the actual bug by changing the order of validity checks, ensuring register validity is checked before atomic_ptr_type_ok() is called.
It also updates some tests that were assuming the previous order of checks.

The second patch adds new tests specifically for the invalid register number case to prevent regression in the future.

Changes:
v3:
- Change invalid register from R11 to R15 in new tests
v2: https://lore.kernel.org/all/[email protected]/
- Just swap atomic_ptr_type_ok() and check_load_mem()/check_store_reg()
- Update some tests that were assuming the previous order of checks
- Add new tests specifically for the invalid register number
v1: https://lore.kernel.org/bpf/[email protected]/

Kohei Enju (2):
bpf: Fix out-of-bounds read in check_atomic_load/store() selftests/bpf: Add selftests for load-acquire/store-release when
register number is invalid

 kernel/bpf/verifier.c                         | 16 +++++++++--
 .../bpf/progs/verifier_load_acquire.c         | 26 +++++++++++++++--
 .../bpf/progs/verifier_store_release.c        | 28 +++++++++++++++++--
 3 files changed, 63 insertions(+), 7 deletions(-)
Signature · 1 line
2.49.0