]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: charge user for creation of BPF maps and programs
authorAlexei Starovoitov <ast@plumgrid.com>
Thu, 8 Oct 2015 05:23:22 +0000 (22:23 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Oct 2015 02:13:36 +0000 (19:13 -0700)
commitbc38a68c07e02476ebdacbe85af149fa6b6a4ff6
treefa5df3122c2576bd2df76f1494c88619b22b6f08
parent6c3d98c5fcd7a0635832b841280192b02d843a0a
bpf: charge user for creation of BPF maps and programs

since eBPF programs and maps use kernel memory consider it 'locked' memory
from user accounting point of view and charge it against RLIMIT_MEMLOCK limit.
This limit is typically set to 64Kbytes by distros, so almost all
bpf+tracing programs would need to increase it, since they use maps,
but kernel charges maximum map size upfront.
For example the hash map of 1024 elements will be charged as 64Kbyte.
It's inconvenient for current users and changes current behavior for root,
but probably worth doing to be consistent root vs non-root.

Similar accounting logic is done by mmap of perf_event.

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/bpf.h
include/linux/sched.h
kernel/bpf/arraymap.c
kernel/bpf/hashtab.c
kernel/bpf/syscall.c