From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
kernel-team@fb.com, yhs@fb.com,
Eduard Zingerman <eddyz87@gmail.com>
Subject: [PATCH bpf-next 0/2] Allow reads from uninit stack
Date: Thu, 16 Feb 2023 20:36:04 +0200 [thread overview]
Message-ID: <20230216183606.2483834-1-eddyz87@gmail.com> (raw)
This patch-set modifies BPF verifier to accept programs that read from
uninitialized stack locations, but only if executed in privileged mode.
This provides significant verification performance gains: 30% to 70% less
processed states for big number of test programs.
The reason for performance gains comes from treating STACK_MISC and
STACK_INVALID as compatible, when cached state is compared to current state
in verifier.c:stacksafe().
The change should not affect safety, because any value read from STACK_MISC
location has full binary range (e.g. 0x00-0xff for byte-sized reads).
Details and measurements are provided in the description for the patch #1.
The change was suggested by Andrii Nakryiko, the initial patch was created
by Alexei Starovoitov. The discussion could be found at [1].
[1] https://lore.kernel.org/bpf/CAADnVQKs2i1iuZ5SUGuJtxWVfGYR9kDgYKhq3rNV+kBLQCu7rA@mail.gmail.com/
Eduard Zingerman (2):
bpf: Allow reads from uninit stack
selftests/bpf: Tests for uninitialized stack reads
kernel/bpf/verifier.c | 10 ++
.../selftests/bpf/prog_tests/uninit_stack.c | 9 ++
.../selftests/bpf/progs/test_global_func10.c | 6 +-
.../selftests/bpf/progs/uninit_stack.c | 55 +++++++++
tools/testing/selftests/bpf/verifier/calls.c | 13 ++-
.../bpf/verifier/helper_access_var_len.c | 104 ++++++++++++------
.../testing/selftests/bpf/verifier/int_ptr.c | 9 +-
.../selftests/bpf/verifier/search_pruning.c | 13 ++-
tools/testing/selftests/bpf/verifier/sock.c | 27 -----
.../selftests/bpf/verifier/spill_fill.c | 7 +-
.../testing/selftests/bpf/verifier/var_off.c | 52 ---------
11 files changed, 171 insertions(+), 134 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/uninit_stack.c
create mode 100644 tools/testing/selftests/bpf/progs/uninit_stack.c
--
2.39.1
next reply other threads:[~2023-02-16 18:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 18:36 Eduard Zingerman [this message]
2023-02-16 18:36 ` [PATCH bpf-next 1/2] bpf: Allow reads from uninit stack Eduard Zingerman
2023-02-17 0:36 ` Andrii Nakryiko
2023-02-17 13:13 ` Eduard Zingerman
2023-02-17 21:58 ` Andrii Nakryiko
2023-02-16 18:36 ` [PATCH bpf-next 2/2] selftests/bpf: Tests for uninitialized stack reads Eduard Zingerman
2023-02-17 0:55 ` Andrii Nakryiko
2023-02-17 13:25 ` Eduard Zingerman
2023-02-17 22:00 ` Andrii Nakryiko
2023-02-17 22:06 ` Eduard Zingerman
2023-02-17 20:37 ` [PATCH bpf-next 0/2] Allow reads from uninit stack Daniel Borkmann
2023-02-17 20:46 ` Eduard Zingerman
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=20230216183606.2483834-1-eddyz87@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=yhs@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