mbox series

[bpf,v4,0/5] Fixes for stack with allow_ptr_leaks

Message ID 20241204044757.1483141-1-memxor@gmail.com (mailing list archive)
Headers show
Series Fixes for stack with allow_ptr_leaks | expand

Message

Kumar Kartikeya Dwivedi Dec. 4, 2024, 4:47 a.m. UTC
Two fixes for usability/correctness gaps when interacting with the stack
without CAP_PERFMON (i.e. with allow_ptr_leaks = false). See the commits
for details. I've verified that the tests fail when run without the fixes.

Changelog:
----------
v3 -> v4
v3: https://lore.kernel.org/bpf/20241202083814.1888784-1-memxor@gmail.com

 * Address Andrii's comments
   * Fix bug paperered over by missing CAP_NET_ADMIN in verifier_mtu
     test
   * Add warning when undefined CAP_ constant is specified, and fail
     test
   * Reorder annotations to be more clear
   * Verify that fixes fail without patches again
 * Add Acked-by from Andrii

v2 -> v3
v2: https://lore.kernel.org/bpf/20241127212026.3580542-1-memxor@gmail.com

 * Address comments from Eduard
   * Fix comment for mark_stack_slot_misc
   * We can simply always return early when stype == STACK_INVALID
   * Drop allow_ptr_leaks conditionals
   * Add Eduard's __caps_unpriv patch into the series
   * Convert test_verifier_mtu to use it
   * Move existing tests to __caps_unpriv annotation and verifier_spill_fill.c
   * Add Acked-by from Eduard

v1 -> v2
v1: https://lore.kernel.org/bpf/20241127185135.2753982-1-memxor@gmail.com

 * Fix CI errors in selftest by removing dependence on BPF_ST

Eduard Zingerman (1):
  selftests/bpf: Introduce __caps_unpriv annotation for tests

Kumar Kartikeya Dwivedi (3):
  bpf: Don't mark STACK_INVALID as STACK_MISC in mark_stack_slot_misc
  selftests/bpf: Add test for reading from STACK_INVALID slots
  selftests/bpf: Add test for narrow spill into 64-bit spilled scalar

Tao Lyu (1):
  bpf: Fix narrow scalar spill onto 64-bit spilled scalar slots

 kernel/bpf/verifier.c                         | 10 ++--
 .../selftests/bpf/prog_tests/verifier.c       | 19 +-------
 tools/testing/selftests/bpf/progs/bpf_misc.h  | 12 +++++
 .../selftests/bpf/progs/verifier_mtu.c        |  4 +-
 .../selftests/bpf/progs/verifier_spill_fill.c | 35 ++++++++++++++
 tools/testing/selftests/bpf/test_loader.c     | 46 +++++++++++++++++++
 6 files changed, 104 insertions(+), 22 deletions(-)


base-commit: 5a6ea7022ff4d2a65ae328619c586d6a8909b48b

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 4, 2024, 5:30 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue,  3 Dec 2024 20:47:52 -0800 you wrote:
> Two fixes for usability/correctness gaps when interacting with the stack
> without CAP_PERFMON (i.e. with allow_ptr_leaks = false). See the commits
> for details. I've verified that the tests fail when run without the fixes.
> 
> Changelog:
> ----------
> v3 -> v4
> v3: https://lore.kernel.org/bpf/20241202083814.1888784-1-memxor@gmail.com
> 
> [...]

Here is the summary with links:
  - [bpf,v4,1/5] bpf: Don't mark STACK_INVALID as STACK_MISC in mark_stack_slot_misc
    https://git.kernel.org/bpf/bpf/c/69772f509e08
  - [bpf,v4,2/5] bpf: Fix narrow scalar spill onto 64-bit spilled scalar slots
    https://git.kernel.org/bpf/bpf/c/b0e66977dc07
  - [bpf,v4,3/5] selftests/bpf: Introduce __caps_unpriv annotation for tests
    https://git.kernel.org/bpf/bpf/c/adfdd9c68566
  - [bpf,v4,4/5] selftests/bpf: Add test for reading from STACK_INVALID slots
    https://git.kernel.org/bpf/bpf/c/f513c3635078
  - [bpf,v4,5/5] selftests/bpf: Add test for narrow spill into 64-bit spilled scalar
    https://git.kernel.org/bpf/bpf/c/19b6dbc006ec

You are awesome, thank you!