Skip to content

bpf: permit map_ptr arithmetic with opcode add and offset 0

Yonghong Song bpf netdev 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v22 patches 0 repliesNew
  2. v3 Latest2 patches 3 repliesIn review
  3. v12 patches 5 repliesSuperseded

Changes in v3 from the cover letter

. only change hashmap subtest to use non-inline version of check_default(),
other subtests still used inline version. This will provide coverage for both inline and non-inline check_default(). (Andrey)

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: permit map_ptr arithmetic with opcode add and offset 0kernel/bpf/verifier.c+4 -01 reply
2/2selftests/bpf: add test for map_ptr arithmetictools/testing/selftests/bpf/progs/map_ptr_kern.c tools/testing/selftests/bpf/verifier/map_ptr.c+41 -12 replies

Reviews trailers per patch

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

PatchAndrii Nakryiko
1/2A-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 bpf-next v3 0/2] bpf: permit map_ptr arithmetic with opcode add and offset 0

With CORE, it is possible that the compiler may produce code like
r1 = 0 // relocation instruction
map_ptr += r1
...
Currently verifier does not allow map_ptr arithmetic, even for adding with 0. This patch set relaxed the condition so the above code can be accepted. Patch #1 is the kernel implementation and Patch #2 added selftest tests to cover the new functionality.

Changelog:
v2 -> v3:
. only change hashmap subtest to use non-inline version of check_default(),
other subtests still used inline version. This will provide coverage for both inline and non-inline check_default(). (Andrey)
v1 -> v2:
. add comment to clarify smin_val represents the const. (Andrii)

Yonghong Song (2):
bpf: permit map_ptr arithmetic with opcode add and offset 0 selftests/bpf: add test for map_ptr arithmetic

 kernel/bpf/verifier.c                         |  4 +++
 .../selftests/bpf/progs/map_ptr_kern.c        | 10 +++++-
 .../testing/selftests/bpf/verifier/map_ptr.c  | 32 +++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
Signature · 1 line
2.24.1