Skip to content

bpf: unprivileged

Alexei Starovoitov linux-api lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 11 repliesIn review
  2. v12 patches 27 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3bpf: enable non-root eBPF programsinclude/linux/bpf.h kernel/bpf/syscall.c kernel/bpf/verifier.c +2 more+120 -158 replies
2/3bpf: charge user for creation of BPF maps and programsinclude/linux/bpf.h include/linux/sched.h kernel/bpf/arraymap.c +2 more+72 -20 replies
3/3bpf: add unprivileged bpf testssamples/bpf/libbpf.h samples/bpf/test_verifier.c+355 -102 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchKees Cook
1/3R-b
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 net-next 0/3] bpf: unprivileged

v1-v2:
- this set logically depends on cb patch
"bpf: fix cb access in socket filter programs":
http://patchwork.ozlabs.org/patch/527391/
which is must have to allow unprivileged programs. Thanks Daniel for finding that issue.
- refactored sysctl to be similar to 'modules_disabled'
- dropped bpf_trace_printk
- split tests into separate patch and added more tests based on discussion

v1 cover letter:
I think it is time to liberate eBPF from CAP_SYS_ADMIN.
As was discussed when eBPF was first introduced two years ago the only piece missing in eBPF verifier is 'pointer leak detection' to make it available to non-root users.
Patch 1 adds this pointer analysis.
The eBPF programs, obviously, need to see and operate on kernel addresses, but with these extra checks they won't be able to pass these addresses to user space.
Patch 2 adds accounting of kernel memory used by programs and maps. It changes behavoir for existing root users, but I think it needs to be done consistently for both root and non-root, since today programs and maps are only limited by number of open FDs (RLIMIT_NOFILE). Patch 2 accounts program's and map's kernel memory as RLIMIT_MEMLOCK.

Unprivileged eBPF is only meaningful for 'socket filter'-like programs. eBPF programs for tracing and TC classifiers/actions will stay root only.

In parallel the bpf fuzzing effort is ongoing and so far we've found only one verifier bug and that was already fixed. The 'constant blinding' pass also being worked on.
It will obfuscate constant-like values that are part of eBPF ISA to make jit spraying attacks even harder.

Alexei Starovoitov (3):
bpf: enable non-root eBPF programs
bpf: charge user for creation of BPF maps and programs
bpf: add unprivileged bpf tests

 include/linux/bpf.h         |    5 +
 include/linux/sched.h       |    2 +-
 kernel/bpf/arraymap.c       |    2 +-
 kernel/bpf/hashtab.c        |    4 +
 kernel/bpf/syscall.c        |   74 ++++++++-
 kernel/bpf/verifier.c       |  106 +++++++++++--
 kernel/sysctl.c             |   13 ++
 net/core/filter.c           |    3 +-
 samples/bpf/libbpf.h        |    8 +
 samples/bpf/test_verifier.c |  357 +++++++++++++++++++++++++++++++++++++++++--
 10 files changed, 547 insertions(+), 27 deletions(-)
Signature · 1 line
1.7.9.5