bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next v3 0/2] bpf: permit map_ptr arithmetic with opcode add and offset 0
@ 2020-09-08 17:57 Yonghong Song
  2020-09-08 17:57 ` [PATCH bpf-next v3 1/2] " Yonghong Song
  2020-09-08 17:57 ` [PATCH bpf-next v3 2/2] selftests/bpf: add test for map_ptr arithmetic Yonghong Song
  0 siblings, 2 replies; 6+ messages in thread
From: Yonghong Song @ 2020-09-08 17:57 UTC (permalink / raw)
  To: bpf, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team

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(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-09-09  1:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 17:57 [PATCH bpf-next v3 0/2] bpf: permit map_ptr arithmetic with opcode add and offset 0 Yonghong Song
2020-09-08 17:57 ` [PATCH bpf-next v3 1/2] " Yonghong Song
2020-09-08 23:11   ` Andrii Nakryiko
2020-09-08 17:57 ` [PATCH bpf-next v3 2/2] selftests/bpf: add test for map_ptr arithmetic Yonghong Song
2020-09-08 23:11   ` Andrii Nakryiko
2020-09-09  1:05     ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).