BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>, <netdev@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH bpf-next v3 0/2] bpf: permit map_ptr arithmetic with opcode add and offset 0
Date: Tue, 8 Sep 2020 10:57:02 -0700	[thread overview]
Message-ID: <20200908175702.2463416-1-yhs@fb.com> (raw)

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


             reply	other threads:[~2020-09-08 17:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08 17:57 Yonghong Song [this message]
2020-09-08 17:57 ` [PATCH bpf-next v3 1/2] bpf: permit map_ptr arithmetic with opcode add and offset 0 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200908175702.2463416-1-yhs@fb.com \
    --to=yhs@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox