Performance oriented customized Linux kernel based on the mainline kernel.
Find a file
Andrii Nakryiko af6eea5743 bpf: Implement bpf_link-based cgroup BPF program attachment
Implement new sub-command to attach cgroup BPF programs and return FD-based
bpf_link back on success. bpf_link, once attached to cgroup, cannot be
replaced, except by owner having its FD. Cgroup bpf_link supports only
BPF_F_ALLOW_MULTI semantics. Both link-based and prog-based BPF_F_ALLOW_MULTI
attachments can be freely intermixed.

To prevent bpf_cgroup_link from keeping cgroup alive past the point when no
BPF program can be executed, implement auto-detachment of link. When
cgroup_bpf_release() is called, all attached bpf_links are forced to release
cgroup refcounts, but they leave bpf_link otherwise active and allocated, as
well as still owning underlying bpf_prog. This is because user-space might
still have FDs open and active, so bpf_link as a user-referenced object can't
be freed yet. Once last active FD is closed, bpf_link will be freed and
underlying bpf_prog refcount will be dropped. But cgroup refcount won't be
touched, because cgroup is released already.

The inherent race between bpf_cgroup_link release (from closing last FD) and
cgroup_bpf_release() is resolved by both operations taking cgroup_mutex. So
the only additional check required is when bpf_cgroup_link attempts to detach
itself from cgroup. At that time we need to check whether there is still
cgroup associated with that link. And if not, exit with success, because
bpf_cgroup_link was already successfully detached.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Roman Gushchin <guro@fb.com>
Link: https://lore.kernel.org/bpf/20200330030001.2312810-2-andriin@fb.com
2020-03-30 17:35:59 -07:00
arch bpf: Support llvm-objcopy for vmlinux BTF 2020-03-19 12:32:38 +01:00
block
certs
crypto
Documentation bpf: lsm: Add Documentation 2020-03-30 01:35:12 +02:00
drivers sfc: fix XDP-redirect in this driver 2020-03-16 18:22:43 -07:00
fs
include bpf: Implement bpf_link-based cgroup BPF program attachment 2020-03-30 17:35:59 -07:00
init bpf, lsm: Make BPF_LSM depend on BPF_EVENTS 2020-03-30 22:57:23 +02:00
ipc
kernel bpf: Implement bpf_link-based cgroup BPF program attachment 2020-03-30 17:35:59 -07:00
lib
LICENSES
mm
net bpf: Don't refcount LISTEN sockets in sk_assign() 2020-03-30 13:45:05 -07:00
samples samples, bpf: Refactor perf_event user program with libbpf bpf_link 2020-03-23 22:27:57 +01:00
scripts bpf: Support llvm-objcopy for vmlinux BTF 2020-03-19 12:32:38 +01:00
security bpf: lsm: Initialize the BPF LSM hooks 2020-03-30 01:34:00 +02:00
sound
tools bpf: Implement bpf_link-based cgroup BPF program attachment 2020-03-30 17:35:59 -07:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS bpf, doc: Add John as official reviewer to BPF subsystem 2020-03-30 22:40:02 +02:00
Makefile
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.