Skip to content

Centralize BPF permission checks

Andrii Nakryiko bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest10 patches 19 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10bpf: move unprivileged checks into map_create() and bpf_prog_load()kernel/bpf/syscall.c+22 -154 replies
2/10bpf: inline map creation logic in map_create() functionkernel/bpf/syscall.c+22 -320 replies
3/10bpf: centralize permissions checks for all BPF map typeskernel/bpf/bloom_filter.c kernel/bpf/bpf_local_storage.c kernel/bpf/bpf_struct_ops.c +11 more+64 -550 replies
4/10bpf: remember if bpf_map was unprivileged and use that consistentlyinclude/linux/bpf.h kernel/bpf/arraymap.c kernel/bpf/map_in_map.c +2 more+65 -324 replies
5/10bpf: drop unnecessary bpf_capable() check in BPF_MAP_FREEZE commandkernel/bpf/syscall.c+5 -40 replies
6/10bpf: keep BPF_PROG_LOAD permission checks clear of validationskernel/bpf/syscall.c+21 -232 replies
7/10bpf: record effective capabilities at BPF prog load timeinclude/linux/bpf.h kernel/bpf/syscall.c+22 -60 replies
8/10bpf: use recorded BPF prog effective caps when fetching helper protosdrivers/media/rc/bpf-lirc.c include/linux/bpf.h kernel/bpf/cgroup.c +6 more+31 -300 replies
9/10bpf: use recorded bpf_capable flag in JIT codearch/arm/net/bpf_jit_32.c arch/arm64/net/bpf_jit_comp.c arch/loongarch/net/bpf_jit.c +11 more+30 -232 replies
10/10bpf: consistenly use program's recorded capabilities in BPF verifierinclude/linux/bpf.h include/linux/filter.h kernel/bpf/core.c +2 more+22 -197 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 00/10] Centralize BPF permission checks

This patch set refactors BPF subsystem permission checks for BPF maps and programs, localizes them in one place, and ensures all parts of BPF ecosystem (BPF verifier and JITs, and their supporting infra) use recorded effective capabilities, stored in respective bpf_map or bpf_prog structs, for further decision making.

This allows for more explicit and centralized handling of BPF-related capabilities and makes for simpler further BPF permission model evolution, to be proposed and discussed in follow up patch sets.

Andrii Nakryiko (10):
bpf: move unprivileged checks into map_create() and bpf_prog_load()
bpf: inline map creation logic in map_create() function
bpf: centralize permissions checks for all BPF map types
bpf: remember if bpf_map was unprivileged and use that consistently
bpf: drop unnecessary bpf_capable() check in BPF_MAP_FREEZE command
bpf: keep BPF_PROG_LOAD permission checks clear of validations
bpf: record effective capabilities at BPF prog load time
bpf: use recorded BPF prog effective caps when fetching helper protos
bpf: use recorded bpf_capable flag in JIT code
bpf: consistenly use program's recorded capabilities in BPF verifier

 arch/arm/net/bpf_jit_32.c                     |   2 +-
 arch/arm64/net/bpf_jit_comp.c                 |   2 +-
 arch/loongarch/net/bpf_jit.c                  |   2 +-
 arch/mips/net/bpf_jit_comp.c                  |   2 +-
 arch/powerpc/net/bpf_jit_comp.c               |   2 +-
 arch/riscv/net/bpf_jit_core.c                 |   3 +-
 arch/s390/net/bpf_jit_comp.c                  |   3 +-
 arch/sparc/net/bpf_jit_comp_64.c              |   2 +-
 arch/x86/net/bpf_jit_comp.c                   |   3 +-
 arch/x86/net/bpf_jit_comp32.c                 |   2 +-
 drivers/media/rc/bpf-lirc.c                   |   2 +-
 include/linux/bpf.h                           |  32 ++-
 include/linux/filter.h                        |   8 +-
 kernel/bpf/arraymap.c                         |  59 +++--
 kernel/bpf/bloom_filter.c                     |   3 -
 kernel/bpf/bpf_local_storage.c                |   3 -
 kernel/bpf/bpf_struct_ops.c                   |   3 -
 kernel/bpf/cgroup.c                           |   6 +-
 kernel/bpf/core.c                             |  22 +-
 kernel/bpf/cpumap.c                           |   4 -
 kernel/bpf/devmap.c                           |   3 -
 kernel/bpf/hashtab.c                          |   6 -
 kernel/bpf/helpers.c                          |   6 +-
 kernel/bpf/lpm_trie.c                         |   3 -
 kernel/bpf/map_in_map.c                       |   3 +-
 kernel/bpf/queue_stack_maps.c                 |   4 -
 kernel/bpf/reuseport_array.c                  |   3 -
 kernel/bpf/stackmap.c                         |   3 -
 kernel/bpf/syscall.c                          | 218 ++++++++++++------
 kernel/bpf/trampoline.c                       |   2 +-
 kernel/bpf/verifier.c                         |  23 +-
 kernel/trace/bpf_trace.c                      |   2 +-
 net/core/filter.c                             |  36 +--
 net/core/sock_map.c                           |   4 -
 net/ipv4/bpf_tcp_ca.c                         |   2 +-
 net/netfilter/nf_bpf_link.c                   |   2 +-
 net/xdp/xskmap.c                              |   4 -
 .../bpf/prog_tests/unpriv_bpf_disabled.c      |   6 +-
 38 files changed, 280 insertions(+), 215 deletions(-)
Signature · 1 line
2.34.1