Skip to content

stricter register ID checking in regsafe()

Eduard Zingerman bpf 1 version 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

  1. v1 Latest7 patches 12 repliesApplied 7/7

Patches in v1 All 7 applied

#Subject and filesSizeRepliesApplied
1/7bpf: regsafe() must not skip check_ids()kernel/bpf/verifier.c+8 -213 repliesApplied
2/7selftests/bpf: test cases for regsafe() bug skipping check_id()tools/testing/selftests/bpf/verifier/direct_packet_access.c tools/testing/selftests/bpf/verifier/value_or_null.c+103 -00 repliesApplied
3/7bpf: states_equal() must build idmap for all function framesinclude/linux/bpf_verifier.h kernel/bpf/verifier.c+4 -33 repliesApplied
4/7selftests/bpf: verify states_equal() maintains idmap across all framestools/testing/selftests/bpf/verifier/calls.c+82 -03 repliesApplied
5/7bpf: use check_ids() for active_lock comparisonkernel/bpf/verifier.c+13 -30 repliesApplied
6/7selftests/bpf: Add pruning test case for bpf_spin_locktools/testing/selftests/bpf/verifier/spin_lock.c+39 -01 replyApplied
7/7selftests/bpf: test case for relaxed prunning of active_lock.idtools/testing/selftests/bpf/verifier/spin_lock.c+75 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/7] stricter register ID checking in regsafe()

This patch-set consists of a series of bug fixes for register ID tracking in verifier.c:states_equal()/regsafe() functions:
- for registers of type PTR_TO_MAP_{KEY,VALUE}, PTR_TO_PACKET[_META] the regsafe() should call check_ids() even if registers are byte-to-byte equal;
- states_equal() must maintain idmap that covers all function frames in the state because functions like mark_ptr_or_null_regs() operate on all registers in the state;
- regsafe() must compare spin lock ids for PTR_TO_MAP_VALUE registers.

The last point covers issue reported by Kumar Kartikeya Dwivedi in [1], I borrowed the test commit from there.
Note, that there is also an issue with register id tracking for scalars described here [2], it would be addressed separately.

[1] https://lore.kernel.org/bpf/[email protected]/
[2] https://lore.kernel.org/bpf/[email protected]/

Eduard Zingerman (6):
bpf: regsafe() must not skip check_ids()
selftests/bpf: test cases for regsafe() bug skipping check_id()
bpf: states_equal() must build idmap for all function frames selftests/bpf: verify states_equal() maintains idmap across all frames
bpf: use check_ids() for active_lock comparison selftests/bpf: test case for relaxed prunning of active_lock.id

Kumar Kartikeya Dwivedi (1):
selftests/bpf: Add pruning test case for bpf_spin_lock

 include/linux/bpf_verifier.h                  |   4 +-
 kernel/bpf/verifier.c                         |  48 ++++----
 tools/testing/selftests/bpf/verifier/calls.c  |  82 +++++++++++++
 .../bpf/verifier/direct_packet_access.c       |  54 +++++++++
 .../selftests/bpf/verifier/spin_lock.c        | 114 ++++++++++++++++++
 .../selftests/bpf/verifier/value_or_null.c    |  49 ++++++++
 6 files changed, 324 insertions(+), 27 deletions(-)
Signature · 1 line
2.34.1