]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
4 years agocgroups: handle lxc.cgroup.use global parameter 3688/head
Christian Brauner [Sun, 21 Feb 2021 10:36:06 +0000 (11:36 +0100)] 
cgroups: handle lxc.cgroup.use global parameter

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: fix cg_legacy_freeze() return type
Christian Brauner [Sun, 21 Feb 2021 10:30:46 +0000 (11:30 +0100)] 
cgroups: fix cg_legacy_freeze() return type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: tweak lxc_write_openat()
Christian Brauner [Sun, 21 Feb 2021 10:28:31 +0000 (11:28 +0100)] 
file_utils: tweak lxc_write_openat()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: improve utility controller handling
Christian Brauner [Sun, 21 Feb 2021 13:32:56 +0000 (14:32 +0100)] 
cgroups: improve utility controller handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/cgroup2_chown/delegate/g
Christian Brauner [Sun, 21 Feb 2021 13:18:28 +0000 (14:18 +0100)] 
cgroups: s/cgroup2_chown/delegate/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: move cgroup2 parameters into substruct
Christian Brauner [Sun, 21 Feb 2021 10:22:59 +0000 (11:22 +0100)] 
cgroups: move cgroup2 parameters into substruct

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/container_limit_path/path_lim/g
Christian Brauner [Sun, 21 Feb 2021 10:18:29 +0000 (11:18 +0100)] 
cgroups: s/container_limit_path/path_lim/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/container_full_path/path_con/g
Christian Brauner [Sun, 21 Feb 2021 10:17:54 +0000 (11:17 +0100)] 
cgroups: s/container_full_path/path_con/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/cgfd_limit/dfd_lim/g
Christian Brauner [Sun, 21 Feb 2021 10:16:30 +0000 (11:16 +0100)] 
cgroups: s/cgfd_limit/dfd_lim/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/cgfd_mon/dfd_mon/g
Christian Brauner [Sun, 21 Feb 2021 10:15:37 +0000 (11:15 +0100)] 
cgroups: s/cgfd_mon/dfd_mon/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/cgfd_con/dfd_con/g
Christian Brauner [Sun, 21 Feb 2021 10:14:53 +0000 (11:14 +0100)] 
cgroups: s/cgfd_con/dfd_con/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/mountpoint/at_mnt/g
Christian Brauner [Sun, 21 Feb 2021 10:11:37 +0000 (11:11 +0100)] 
cgroups: s/mountpoint/at_mnt/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/container_base_path/at_base/g
Christian Brauner [Sun, 21 Feb 2021 10:09:27 +0000 (11:09 +0100)] 
cgroups: s/container_base_path/at_base/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: rename cgroupfs mount fd
Christian Brauner [Sun, 21 Feb 2021 09:54:23 +0000 (10:54 +0100)] 
cgroups: rename cgroupfs mount fd

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: simplify and fix mounting on non-cgroup namespace aware kernels
Christian Brauner [Sun, 21 Feb 2021 00:40:11 +0000 (01:40 +0100)] 
cgroups: simplify and fix mounting on non-cgroup namespace aware kernels

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: introduce cgroup hierarchy type
Christian Brauner [Sun, 21 Feb 2021 00:28:45 +0000 (01:28 +0100)] 
cgroups: introduce cgroup hierarchy type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: remove unused helpers
Christian Brauner [Sun, 21 Feb 2021 00:25:49 +0000 (01:25 +0100)] 
cgroups: remove unused helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/add_hierarchy()/cgroup_hierarchy_add()/g
Christian Brauner [Sun, 21 Feb 2021 00:09:33 +0000 (01:09 +0100)] 
cgroups: s/add_hierarchy()/cgroup_hierarchy_add()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: split delegation checks into separate helpers
Christian Brauner [Sun, 21 Feb 2021 00:05:39 +0000 (01:05 +0100)] 
cgroups: split delegation checks into separate helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: simplify string list handling
Christian Brauner [Sat, 20 Feb 2021 23:46:23 +0000 (00:46 +0100)] 
cgroups: simplify string list handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: rework cgroup initialization
Christian Brauner [Sat, 20 Feb 2021 01:01:18 +0000 (02:01 +0100)] 
cgroups: rework cgroup initialization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: split out unified cgroup helpers
Christian Brauner [Sat, 20 Feb 2021 00:31:05 +0000 (01:31 +0100)] 
cgroups: split out unified cgroup helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomemory_utils: adapt to new pointer error macros
Christian Brauner [Sat, 20 Feb 2021 02:17:10 +0000 (03:17 +0100)] 
memory_utils: adapt to new pointer error macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomacro: add pointer error encoding support
Christian Brauner [Sat, 20 Feb 2021 00:30:33 +0000 (01:30 +0100)] 
macro: add pointer error encoding support

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocompiler: add likely() and unlikely() support
Christian Brauner [Sat, 20 Feb 2021 00:32:49 +0000 (01:32 +0100)] 
compiler: add likely() and unlikely() support

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/basecginfo/cgroup_info/g
Christian Brauner [Sat, 20 Feb 2021 00:10:53 +0000 (01:10 +0100)] 
cgroups: s/basecginfo/cgroup_info/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: simplify current cgroup retrieval on pure unified cgroup layouts
Christian Brauner [Sat, 20 Feb 2021 00:07:43 +0000 (01:07 +0100)] 
cgroups: simplify current cgroup retrieval on pure unified cgroup layouts

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: tweak return values
Christian Brauner [Fri, 19 Feb 2021 23:49:25 +0000 (00:49 +0100)] 
cgroups: tweak return values

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: tweak lxc.cgroup.use handling in __cgroup_init()
Christian Brauner [Fri, 19 Feb 2021 23:42:51 +0000 (00:42 +0100)] 
cgroups: tweak lxc.cgroup.use handling in __cgroup_init()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: s/must_copy_string()/strdup()/g
Christian Brauner [Fri, 19 Feb 2021 23:39:47 +0000 (00:39 +0100)] 
cgroups: s/must_copy_string()/strdup()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: avoid additional variable for single access
Christian Brauner [Fri, 19 Feb 2021 23:38:57 +0000 (00:38 +0100)] 
cgroups: avoid additional variable for single access

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: fix prune_init_scope()
Christian Brauner [Fri, 19 Feb 2021 17:25:30 +0000 (18:25 +0100)] 
cgroups: fix prune_init_scope()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostring_utils: move lxc_iterate_parts()
Christian Brauner [Fri, 19 Feb 2021 16:39:09 +0000 (17:39 +0100)] 
string_utils: move lxc_iterate_parts()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3684 from brauner/2021-02-18/fixes_2
Stéphane Graber [Fri, 19 Feb 2021 17:04:56 +0000 (12:04 -0500)] 
Merge pull request #3684 from brauner/2021-02-18/fixes_2

bpf: device cgroup improvements

4 years agoMerge pull request #3687 from brauner/2021-02-19/fixes
Stéphane Graber [Fri, 19 Feb 2021 16:58:43 +0000 (11:58 -0500)] 
Merge pull request #3687 from brauner/2021-02-19/fixes

lsm: fixes

4 years agodoc: tweak cgroup headline 3684/head
Christian Brauner [Fri, 19 Feb 2021 12:50:35 +0000 (13:50 +0100)] 
doc: tweak cgroup headline

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agodoc: epxlain eBPF-based device controller semantics
Christian Brauner [Fri, 19 Feb 2021 12:41:51 +0000 (13:41 +0100)] 
doc: epxlain eBPF-based device controller semantics

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agodoc: add missing ".[controller file] suffix to lxc.cgroup{2}. key explanations
Christian Brauner [Fri, 19 Feb 2021 12:39:42 +0000 (13:39 +0100)] 
doc: add missing ".[controller file] suffix to lxc.cgroup{2}. key explanations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: update device cgroup semantics
Christian Brauner [Fri, 19 Feb 2021 10:50:29 +0000 (11:50 +0100)] 
bpf: update device cgroup semantics

LXC has supported the bpf device controlller for a while now. A bpf device
program can be attached to the container's cgroup if this is a pure cgroup2
host.

The format for specifying device rules for the cgroup2 bpf device controller is
the same as for the legacy cgroup device controller; only the configuration key
prefix has to change. Specifically, device rules for the legacy cgroup device
controller are specified by via lxc.cgroup.devices.{allow,deny} whereas for the
cgroup2 bpf device controller lxc.cgroup2.devices.{allow,deny} must be used.

The following semantics apply:
1. The device rule "lxc.cgroup2.devices.deny = a" will cause LXC to instruct
   the kernel to block access to all devices by default. To grant access to
   devices "allow device rules" must be added via the
   "lxc.cgroup2.devices.allow" key. This is referred to as a "allowlist" device
   program.
2. The device rule "lxc.cgroup2.devices.allow = a" will cause LXC to instruct
   the kernel to allow access to all devices by default. To deny access to
   devices "deny device rules" must be added via "lxc.cgroup2.devices.deny"
   key. This is referred to as a "denylist" device program.
3. Specifying a rule as explained in 1. or 2. will cause all previous rules to
   be cleared, i.e. the device list will be reset.

For example the set of rules:

lxc.cgroup2.devices.deny = a
lxc.cgroup2.devices.allow = c *:* m
lxc.cgroup2.devices.allow = b *:* m
lxc.cgroup2.devices.allow = c 1:3 rwm

implements a "allowlist" device program, i.e. the kernel will block access to
all devices not specifically allowed in this list. This particular program
states that all character and block devices might be created but only /dev/null
might be read or written.

If we to switch to the set of rules to:

lxc.cgroup2.devices.allow = a
lxc.cgroup2.devices.deny = c *:* m
lxc.cgroup2.devices.deny = b *:* m
lxc.cgroup2.devices.deny = c 1:3 rwm

then LXC would instruct the kernel to implement a "denylist", i.e. the kernel
will allow access to all devices not specifically denied in this list. This
particular program states that no character devices or block devices might be
created and that /dev/null is not allow allowed to be read, written, or
created.

Consider the same program but followed by a rule as explained in 1. or 2.:

lxc.cgroup2.devices.allow = a
lxc.cgroup2.devices.deny = c *:* m
lxc.cgroup2.devices.deny = b *:* m
lxc.cgroup2.devices.deny = c 1:3 rwm
lxc.cgroup2.devices.allow = a

The last line will cause LXC to reset the device list without changing the type
of device program.

lxc.cgroup2.devices.allow = a
lxc.cgroup2.devices.deny = c *:* m
lxc.cgroup2.devices.deny = b *:* m
lxc.cgroup2.devices.deny = c 1:3 rwm
lxc.cgroup2.devices.deny = a

The last line will cause LXC to reset the device list and switch from a
"allowlist" program to a "denylist" program.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: tweak bpf_device_cgroup_prepare()
Christian Brauner [Fri, 19 Feb 2021 10:31:20 +0000 (11:31 +0100)] 
cgroups: tweak bpf_device_cgroup_prepare()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: expose lxc_clear_cgroup2_devices()
Christian Brauner [Fri, 19 Feb 2021 10:24:49 +0000 (11:24 +0100)] 
conf: expose lxc_clear_cgroup2_devices()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: improve lxc_clear_cgroups()
Christian Brauner [Fri, 19 Feb 2021 10:12:22 +0000 (11:12 +0100)] 
conf: improve lxc_clear_cgroups()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: fix typos
Christian Brauner [Fri, 19 Feb 2021 03:33:39 +0000 (04:33 +0100)] 
bpf: fix typos

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: comment bpf_cgroup_devices_update()
Christian Brauner [Fri, 19 Feb 2021 03:31:40 +0000 (04:31 +0100)] 
bpf: comment bpf_cgroup_devices_update()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: only update bpf device program if really needed
Christian Brauner [Fri, 19 Feb 2021 03:03:09 +0000 (04:03 +0100)] 
commands: only update bpf device program if really needed

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: make device cgroup handling smarter and simpler
Christian Brauner [Fri, 19 Feb 2021 02:45:06 +0000 (03:45 +0100)] 
cgroups: make device cgroup handling smarter and simpler

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: ensure no garbage is returned
Christian Brauner [Thu, 18 Feb 2021 20:34:22 +0000 (21:34 +0100)] 
cgroups: ensure no garbage is returned

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolsm: twek apparmor_process_label_get() 3687/head
Christian Brauner [Fri, 19 Feb 2021 13:40:33 +0000 (14:40 +0100)] 
lsm: twek apparmor_process_label_get()

Fixes: Coverity 1473189
Fixes: Coverity 1473190
Fixes: 47f4914d88df ("apparmor: prefer /proc/.../attr/apparmor/current over legacy interface")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: allow fd_to_buf() to fail for real
Christian Brauner [Fri, 19 Feb 2021 13:32:36 +0000 (14:32 +0100)] 
file_utils: allow fd_to_buf() to fail for real

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3686 from cyphar/apparmor-attr-subdir
Christian Brauner [Fri, 19 Feb 2021 12:15:31 +0000 (13:15 +0100)] 
Merge pull request #3686 from cyphar/apparmor-attr-subdir

apparmor: prefer /proc/.../attr/apparmor/current over legacy interface

4 years agoapparmor: prefer /proc/.../attr/apparmor/current over legacy interface 3686/head
Aleksa Sarai [Fri, 19 Feb 2021 09:45:37 +0000 (20:45 +1100)] 
apparmor: prefer /proc/.../attr/apparmor/current over legacy interface

It turns out that since Linux 5.1 there are now per-LSM subdirectories
for major LSMs, which users are recommended to use over the "legacy"
top-level /proc/$pid/attr/... files[1]:

> Process attributes associated with “major” security modules should be
> accessed and maintained using the special files in /proc/.../attr. A
> security module may maintain a module specific subdirectory there,
> named after the module. /proc/.../attr/smack is provided by the Smack
> security module and contains all its special files. The files directly
> in /proc/.../attr remain as legacy interfaces for modules that provide
> subdirectories.

AppArmor has had such a directory since Linux 5.8[2], and it turns out
that with certain CONFIG_LSM configurations you can end up with AppArmor
files not being accessible from the legacy interface. Arch Linux
recently added BPF as one of the enabled LSM in their configuration, and
this broke runc[3] and LXC.

The solution is to first try to use /proc/$pid/attr/apparmor/current and
fall back to /proc/$pid/attr/current if the former is not available.

[1]: https://www.kernel.org/doc/html/latest/admin-guide/LSM/index.html
[2]: Linux 5.8 ; commit 6413f852ce08 ("apparmor: add proc subdir to attrs")
[3]: https://github.com/opencontainers/runc/issues/2801

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
4 years agoapparmor: clean up apparmor_process_label_get
Aleksa Sarai [Fri, 19 Feb 2021 09:24:18 +0000 (20:24 +1100)] 
apparmor: clean up apparmor_process_label_get

Rather than open-coding file reading and retry semantics and
implementing the path generation logic separately to
apparmor_process_label_fd_get, refactor the logic so that it looks
closer to the pidfd version.

This will make it easier to implement the two-step handling for
/proc/self/attr/apparmor/current and makes this code slightly less
confusing.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
4 years agoMerge pull request #3681 from brauner/2021-02-18/cgroups
Stéphane Graber [Thu, 18 Feb 2021 16:52:52 +0000 (11:52 -0500)] 
Merge pull request #3681 from brauner/2021-02-18/cgroups

cgroups: fixes & bpf rework

4 years agoMerge pull request #3682 from brauner/2021-02-18/fixes
Stéphane Graber [Thu, 18 Feb 2021 16:42:17 +0000 (11:42 -0500)] 
Merge pull request #3682 from brauner/2021-02-18/fixes

console: fixes

4 years agoconf: don't log garbage 3682/head
Christian Brauner [Thu, 18 Feb 2021 16:08:11 +0000 (17:08 +0100)] 
conf: don't log garbage

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostart: fix non-daemonized and application containers
Christian Brauner [Thu, 18 Feb 2021 16:00:54 +0000 (17:00 +0100)] 
start: fix non-daemonized and application containers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use saner mode for console
Christian Brauner [Thu, 18 Feb 2021 15:40:52 +0000 (16:40 +0100)] 
conf: use saner mode for console

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: simplify bpf (device) program freeing 3681/head
Christian Brauner [Thu, 18 Feb 2021 15:26:16 +0000 (16:26 +0100)] 
bpf: simplify bpf (device) program freeing

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: make bpf_program_cgroup_attach() static
Christian Brauner [Thu, 18 Feb 2021 15:21:04 +0000 (16:21 +0100)] 
bpf: make bpf_program_cgroup_attach() static

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: prevent double-close
Christian Brauner [Thu, 18 Feb 2021 15:13:45 +0000 (16:13 +0100)] 
bpf: prevent double-close

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: use close_equal() and free_equal()
Christian Brauner [Thu, 18 Feb 2021 14:52:52 +0000 (15:52 +0100)] 
cgroups: use close_equal() and free_equal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomemory_utils: add close_equal() and free_equal()
Christian Brauner [Thu, 18 Feb 2021 14:52:35 +0000 (15:52 +0100)] 
memory_utils: add close_equal() and free_equal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxccontainer: fix reboot logging
Christian Brauner [Thu, 18 Feb 2021 14:39:17 +0000 (15:39 +0100)] 
lxccontainer: fix reboot logging

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: rework live device cgroup update
Christian Brauner [Thu, 18 Feb 2021 13:50:03 +0000 (14:50 +0100)] 
bpf: rework live device cgroup update

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocompiler: fix fallthrough attribute
Christian Brauner [Thu, 18 Feb 2021 13:42:39 +0000 (14:42 +0100)] 
compiler: fix fallthrough attribute

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: fix return values in bpf_program_cgroup_attach()
Christian Brauner [Thu, 18 Feb 2021 13:42:15 +0000 (14:42 +0100)] 
bpf: fix return values in bpf_program_cgroup_attach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: let bpf_list_add_device() take the device list directly
Christian Brauner [Thu, 18 Feb 2021 12:35:03 +0000 (13:35 +0100)] 
bpf: let bpf_list_add_device() take the device list directly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: add and use bpf_cgroup_devices_attach() helper
Christian Brauner [Thu, 18 Feb 2021 12:20:40 +0000 (13:20 +0100)] 
bpf: add and use bpf_cgroup_devices_attach() helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: remove compile-time bpf support detection
Christian Brauner [Thu, 18 Feb 2021 11:41:57 +0000 (12:41 +0100)] 
cgroups: remove compile-time bpf support detection

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: vendor bpf headers
Christian Brauner [Thu, 18 Feb 2021 11:29:50 +0000 (12:29 +0100)] 
bpf: vendor bpf headers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: handling missing defines
Christian Brauner [Thu, 18 Feb 2021 11:02:54 +0000 (12:02 +0100)] 
bpf: handling missing defines

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: rework bpf_program_cgroup_detach()
Christian Brauner [Thu, 18 Feb 2021 10:45:41 +0000 (11:45 +0100)] 
bpf: rework bpf_program_cgroup_detach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: rework bpf devices BPF_F_REPLACE codepath
Christian Brauner [Thu, 18 Feb 2021 10:37:55 +0000 (11:37 +0100)] 
commands: rework bpf devices BPF_F_REPLACE codepath

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: don't close invalid fd, simply swap
Christian Brauner [Thu, 18 Feb 2021 10:37:28 +0000 (11:37 +0100)] 
bpf: don't close invalid fd, simply swap

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: use __u32 not uint32_t
Christian Brauner [Thu, 18 Feb 2021 10:36:32 +0000 (11:36 +0100)] 
bpf: use __u32 not uint32_t

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomacro: add swap helper
Christian Brauner [Thu, 18 Feb 2021 10:23:30 +0000 (11:23 +0100)] 
macro: add swap helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: replace bpf program on update
Christian Brauner [Thu, 18 Feb 2021 09:43:10 +0000 (10:43 +0100)] 
commands: replace bpf program on update

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: improve bpf device program management
Christian Brauner [Thu, 18 Feb 2021 09:41:52 +0000 (10:41 +0100)] 
commands: improve bpf device program management

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: improve bpf device program management
Christian Brauner [Thu, 18 Feb 2021 09:39:39 +0000 (10:39 +0100)] 
cgroups: improve bpf device program management

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: add helpers for better bpf device program management
Christian Brauner [Thu, 18 Feb 2021 09:39:14 +0000 (10:39 +0100)] 
bpf: add helpers for better bpf device program management

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: improve bpf device program handling
Christian Brauner [Thu, 18 Feb 2021 09:24:10 +0000 (10:24 +0100)] 
cgroups: improve bpf device program handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: make device cgroups semantics clearer
Christian Brauner [Thu, 18 Feb 2021 09:23:29 +0000 (10:23 +0100)] 
cgroups: make device cgroups semantics clearer

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: enable helpers to let caller replace existing bpf programs
Christian Brauner [Thu, 18 Feb 2021 09:19:27 +0000 (10:19 +0100)] 
bpf: enable helpers to let caller replace existing bpf programs

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: align struct initialization
Christian Brauner [Thu, 18 Feb 2021 09:18:56 +0000 (10:18 +0100)] 
bpf: align struct initialization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: use return macros
Christian Brauner [Thu, 18 Feb 2021 09:17:21 +0000 (10:17 +0100)] 
bpf: use return macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: introduce lxc_bpf_devices_rule_t type
Christian Brauner [Thu, 18 Feb 2021 09:15:39 +0000 (10:15 +0100)] 
conf: introduce lxc_bpf_devices_rule_t type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: use cgroup fd directly instead of paths
Christian Brauner [Wed, 17 Feb 2021 23:51:14 +0000 (00:51 +0100)] 
bpf: use cgroup fd directly instead of paths

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: kill monitor_full_path
Christian Brauner [Wed, 17 Feb 2021 23:38:47 +0000 (00:38 +0100)] 
cgroups: kill monitor_full_path

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: free correct path
Christian Brauner [Wed, 17 Feb 2021 23:35:22 +0000 (00:35 +0100)] 
cgroups: free correct path

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoutils: fix print_r() debugging helper
Christian Brauner [Wed, 17 Feb 2021 21:54:44 +0000 (22:54 +0100)] 
utils: fix print_r() debugging helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: fix error values
Christian Brauner [Wed, 17 Feb 2021 21:48:40 +0000 (22:48 +0100)] 
cgroups: fix error values

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: don't overwrite type
Christian Brauner [Wed, 17 Feb 2021 17:49:20 +0000 (18:49 +0100)] 
cgroups: don't overwrite type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: make it extremely obvious that we're transitioning from a flag to a type
Christian Brauner [Wed, 17 Feb 2021 15:59:40 +0000 (16:59 +0100)] 
cgroups: make it extremely obvious that we're transitioning from a flag to a type

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3680 from brauner/2021-02-17/cgroups_2
Stéphane Graber [Wed, 17 Feb 2021 17:30:57 +0000 (12:30 -0500)] 
Merge pull request #3680 from brauner/2021-02-17/cgroups_2

cgroups: fourth batch of cgroup fixes

4 years agocgroups: create controller directories if missing 3680/head
Christian Brauner [Wed, 17 Feb 2021 15:40:48 +0000 (16:40 +0100)] 
cgroups: create controller directories if missing

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: use non-flag based checking now that we switched all codepaths over
Christian Brauner [Wed, 17 Feb 2021 15:28:42 +0000 (16:28 +0100)] 
cgroups: use non-flag based checking now that we switched all codepaths over

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use brackets to clarify check semantics
Christian Brauner [Wed, 17 Feb 2021 15:24:50 +0000 (16:24 +0100)] 
conf: use brackets to clarify check semantics

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: validate that only a single cgroup mount type is set
Christian Brauner [Wed, 17 Feb 2021 15:23:51 +0000 (16:23 +0100)] 
cgroups: validate that only a single cgroup mount type is set

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: prevent cgroup mount type overwrite
Christian Brauner [Wed, 17 Feb 2021 15:23:20 +0000 (16:23 +0100)] 
cgroups: prevent cgroup mount type overwrite

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: ensure that cgroup_root is initialized in legacy codepaths
Christian Brauner [Wed, 17 Feb 2021 15:29:56 +0000 (16:29 +0100)] 
cgroups: ensure that cgroup_root is initialized in legacy codepaths

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>