public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next  0/2] Allow reads from uninit stack
@ 2023-02-16 18:36 Eduard Zingerman
  2023-02-16 18:36 ` [PATCH bpf-next 1/2] bpf: " Eduard Zingerman
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Eduard Zingerman @ 2023-02-16 18:36 UTC (permalink / raw)
  To: bpf, ast; +Cc: andrii, daniel, martin.lau, kernel-team, yhs, Eduard Zingerman

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


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

end of thread, other threads:[~2023-02-17 22:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-16 18:36 [PATCH bpf-next 0/2] Allow reads from uninit stack Eduard Zingerman
2023-02-16 18:36 ` [PATCH bpf-next 1/2] bpf: " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox