BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH bpf-next 0/2] [bpf] allow s32/u32 return types in verifier for bpf helpers
Date: Sun, 17 Nov 2019 10:27:04 -0800	[thread overview]
Message-ID: <20191117182704.656602-1-yhs@fb.com> (raw)

Currently, for all helpers with integer return type,
the verifier permits a single return type, RET_INTEGER,
which represents 64-bit return value from the helper,
and the verifier will assign 64-bit value ranges for these
return values. Such an assumption is different
from what compiler sees and the generated code with
llvm alu32 mode, and may lead verification failure.

This patch enhanced verifier to handle s32/u32 helper
return values properly to avoid verification failure
due to conservative return value range marking.
Patch #1 commit message has details of explanation and
Patch #2 added test cases to selftests test_verifier.

Yonghong Song (2):
  [bpf] allow s32/u32 return types in verifier for bpf helpers
  [tools/bpf] add verifier test for s32/u32 helper return values

 include/linux/bpf.h                           |  4 +-
 kernel/bpf/helpers.c                          |  8 +--
 kernel/bpf/verifier.c                         | 30 +++++++++--
 kernel/trace/bpf_trace.c                      |  4 +-
 net/core/filter.c                             | 16 +++---
 .../selftests/bpf/verifier/helper_ret.c       | 50 +++++++++++++++++++
 6 files changed, 94 insertions(+), 18 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/verifier/helper_ret.c

-- 
2.17.1


             reply	other threads:[~2019-11-17 18:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-17 18:27 Yonghong Song [this message]
2019-11-17 18:27 ` [PATCH bpf-next 1/2] [bpf] allow s32/u32 return types in verifier for bpf helpers Yonghong Song
2019-11-19  3:31   ` Alexei Starovoitov
2019-11-17 18:27 ` [PATCH bpf-next 2/2] [tools/bpf] add verifier test for s32/u32 helper return values Yonghong Song

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=20191117182704.656602-1-yhs@fb.com \
    --to=yhs@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /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