Skip to content

libbpf: move arena variables out of the zero page

Emil Tsalapatis bpf 5 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. v4 Latest5 patches 3 repliesApplied 5/5
  2. v35 patches 9 repliesSuperseded
  3. v2 posting 2/24 patches 5 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 posting 1/24 patches9 repliesSuperseded
v14 patches2 repliesSuperseded

Patches in v4 All 5 applied

#Subject and filesSizeRepliesApplied
1/5selftests/bpf: explicitly account for globals in verifier_arena_largetools/testing/selftests/bpf/progs/verifier_arena_large.c+11 -40 repliesApplied
2/5bpf/verifier: do not limit maximum direct offset into arena mapkernel/bpf/verifier.c tools/testing/selftests/bpf/verifier/direct_value_access.c+2 -73 repliesApplied
3/5libbpf: turn relo_core->sym_off unsignedtools/lib/bpf/libbpf.c+7 -70 repliesApplied
4/5libbpf: move arena globals to the end of the arenatools/lib/bpf/libbpf.c tools/testing/selftests/bpf/progs/verifier_arena_large.c+22 -70 repliesApplied
5/5selftests/bpf: add tests for the arena offset of globalstools/testing/selftests/bpf/prog_tests/verifier.c tools/testing/selftests/bpf/progs/verifier_arena_globals1.c tools/testing/selftests/bpf/progs/verifier_arena_globals2.c+140 -00 repliesApplied

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchEduard Zingerman
1/5R-b
2/5
3/5A-b
4/5A-b
5/5

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 v4 0/5] libbpf: move arena variables out of the zero page

Modify libbpf to place arena globals at the end of the arena mapping instead of the very beginning. This allows programs to leave the "zero page" of the arena unmapped, so that NULL arena pointer dereferences trigger a page fault and associated backtrace in BPF streams. In contrast, the current policy of placing global data in the zero pages means that NULL dereferences silently corrupt global data, e.g, arena qspinlock state. This makes arena bugs more difficult to debug.

The patchset adds code to libbpf to move global arena data to the end of the arena. At load time, libbpf adjusts each symbol's location within the arena to point to the right location in the arena. The patchset also adjusts the arena skeleton pointer to point to the arena globals, now that they are not in the beginning of the arena region.

CHANGESET
=========

v3->v4: (https://lore.kernel.org/bpf/[email protected]/T/#t)

- Added Acks by Eduard
- Changed jumptable sym_off to unsigned int for consistency (AI)
- Adjusted selftests to ensure arena globals are actually mapped in (Eduard)
- (Patch 2) Adjusted selftests that were failing because they were expecting the now removed "direct map offset" error message

v2->v3: (https://lore.kernel.org/bpf/[email protected]/)

- Remove unnecessary kernel bounds check in resolve_pseudo_ldimm64 (Andrii)
- Added patch to turn sym_off unsigned to prevent overflow (AI)
- Remove obsolete references to offsets from test patch description (Andrii)
- Use size_t for arena_data_off (Andrii)
- Remove extra mutable variable from offset calculations (Andrii)

v1->v2: (https://lore.kernel.org/bpf/[email protected])

- Moved globals to the end of the mapping: (Andrii)
- Removed extra parameter for offset and parameter picking logic
- Removed padding in the skeleton
- Removed additional libbpf call
- Added Reviewed-by from Eduard on patch 1

Emil Tsalapatis (5):
selftests/bpf: explicitly account for globals in verifier_arena_large bpf/verifier: do not limit maximum direct offset into arena map
libbpf: turn relo_core->sym_off unsigned
libbpf: move arena globals to the end of the arena selftests/bpf: add tests for the arena offset of globals

 kernel/bpf/verifier.c                         |  5 --
 tools/lib/bpf/libbpf.c                        | 31 ++++---
 .../selftests/bpf/prog_tests/verifier.c       |  4 +
 .../bpf/progs/verifier_arena_globals1.c       | 87 +++++++++++++++++++
 .../bpf/progs/verifier_arena_globals2.c       | 49 +++++++++++
 .../bpf/progs/verifier_arena_large.c          | 21 ++++-
 .../bpf/verifier/direct_value_access.c        |  4 +-
 7 files changed, 179 insertions(+), 22 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_arena_globals1.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_arena_globals2.c
Signature · 1 line
2.49.0