mbox series

[bpf,v5,0/3] bpf: fix accesses to uninit stack slots

Message ID 20231208032519.260451-1-andreimatei1@gmail.com (mailing list archive)
Headers show
Series bpf: fix accesses to uninit stack slots | expand

Message

Andrei Matei Dec. 8, 2023, 3:25 a.m. UTC
Fix two related issues issues around verifying stack accesses:
1. accesses to uninitialized stack memory was allowed inconsistently
2. the maximum stack depth needed for a program was not always
maintained correctly

The two issues are fixed together in one commit because the code for one
affects the other.

V4 to V5:
- target bpf-next (Alexei)

V3 to V4:
- minor fixup to comment in patch 1 (Eduard)
- C89-style in patch 3 (Andrii)

V2 to V3:
- address review comments from Andrii and Eduard
- drop new verifier tests in favor of editing existing tests to check
  for stack depth
- append a patch with a bit of cleanup coming out of the previous review


Andrei Matei (3):
  bpf: add some comments to stack representation
  bpf: fix accesses to uninit stack slots
  bpf: minor cleanup around stack bounds

 include/linux/bpf_verifier.h                  | 14 ++++
 kernel/bpf/verifier.c                         | 76 +++++++++----------
 tools/testing/selftests/bpf/progs/iters.c     |  2 +-
 .../selftests/bpf/progs/test_global_func16.c  |  2 +-
 .../bpf/progs/verifier_basic_stack.c          |  8 +-
 .../selftests/bpf/progs/verifier_int_ptr.c    |  5 +-
 .../selftests/bpf/progs/verifier_raw_stack.c  |  5 +-
 .../selftests/bpf/progs/verifier_var_off.c    | 62 ++++++++++++---
 .../selftests/bpf/verifier/atomic_cmpxchg.c   | 11 ---
 tools/testing/selftests/bpf/verifier/calls.c  |  4 +-
 10 files changed, 115 insertions(+), 74 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 8, 2023, 11:10 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Thu,  7 Dec 2023 22:25:16 -0500 you wrote:
> Fix two related issues issues around verifying stack accesses:
> 1. accesses to uninitialized stack memory was allowed inconsistently
> 2. the maximum stack depth needed for a program was not always
> maintained correctly
> 
> The two issues are fixed together in one commit because the code for one
> affects the other.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v5,1/3] bpf: add some comments to stack representation
    https://git.kernel.org/bpf/bpf-next/c/92e1567ee3e3
  - [bpf-next,v5,2/3] bpf: fix accesses to uninit stack slots
    https://git.kernel.org/bpf/bpf-next/c/6b4a64bafd10
  - [bpf-next,v5,3/3] bpf: minor cleanup around stack bounds
    https://git.kernel.org/bpf/bpf-next/c/2929bfac006d

You are awesome, thank you!