]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
3 years agocommands: extend rsp_one_fd() to also handle additional data
Christian Brauner [Wed, 24 Feb 2021 14:31:12 +0000 (15:31 +0100)]
commands: extend rsp_one_fd() to also handle additional data

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agofile_utils: actually open the file for reading
Christian Brauner [Wed, 24 Feb 2021 14:25:19 +0000 (15:25 +0100)]
file_utils: actually open the file for reading

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: set rsp.ret to 0 for lxc_cmd_get_cgroup_ctx_callback()
Christian Brauner [Wed, 24 Feb 2021 10:53:53 +0000 (11:53 +0100)]
commands: set rsp.ret to 0 for lxc_cmd_get_cgroup_ctx_callback()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: s/cgroup_layout/layout/g
Christian Brauner [Wed, 24 Feb 2021 10:31:02 +0000 (11:31 +0100)]
cgroups: s/cgroup_layout/layout/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD
Christian Brauner [Wed, 24 Feb 2021 10:11:08 +0000 (11:11 +0100)]
commands: add LXC_CMD_GET_CGROUP_FD and LXC_CMD_GET_LIMIT_CGROUP_FD

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: s/_LIMITING_/_LIMIT_/g and s/_limiting_/_limit_/g
Christian Brauner [Wed, 24 Feb 2021 09:58:43 +0000 (10:58 +0100)]
commands: s/_LIMITING_/_LIMIT_/g and s/_limiting_/_limit_/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: simplify lxc_cmd_get_cgroup_ctx()
Christian Brauner [Wed, 24 Feb 2021 08:47:40 +0000 (09:47 +0100)]
commands: simplify lxc_cmd_get_cgroup_ctx()

Instead of allowing individual hierarchy fd retrieval through
lxc_cmd_get_cgroup_ctx() let's add a dedicated method instead.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: fix alignment for lxc_cmd_get_cgroup_ctx()
Christian Brauner [Wed, 24 Feb 2021 08:46:07 +0000 (09:46 +0100)]
commands: fix alignment for lxc_cmd_get_cgroup_ctx()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: handle fallback gracefully
Christian Brauner [Wed, 24 Feb 2021 08:41:32 +0000 (09:41 +0100)]
cgroups: handle fallback gracefully

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: make use of ERRNO_IS_NOT_SUPPORTED()
Christian Brauner [Wed, 24 Feb 2021 08:37:13 +0000 (09:37 +0100)]
cgroups: make use of ERRNO_IS_NOT_SUPPORTED()

This will hopefully prevent backwards compatibility fallback errors.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoerror_utils: copy over Lennart's IN_SET()
Christian Brauner [Wed, 24 Feb 2021 08:19:12 +0000 (09:19 +0100)]
error_utils: copy over Lennart's IN_SET()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: tweak return values
Christian Brauner [Wed, 24 Feb 2021 08:17:03 +0000 (09:17 +0100)]
commands: tweak return values

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoerror_utils: move error helper to separate header
Christian Brauner [Wed, 24 Feb 2021 08:16:09 +0000 (09:16 +0100)]
error_utils: move error helper to separate header

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: simple variable reordering
Christian Brauner [Wed, 24 Feb 2021 07:58:56 +0000 (08:58 +0100)]
cgroups: simple variable reordering

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3692 from brauner/2021-02-23/fixes
Stéphane Graber [Wed, 24 Feb 2021 01:17:52 +0000 (20:17 -0500)]
Merge pull request #3692 from brauner/2021-02-23/fixes

build fix & cgroup braino

3 years agoattach: be paranoid about file descriptors
Christian Brauner [Wed, 24 Feb 2021 00:53:05 +0000 (01:53 +0100)]
attach: be paranoid about file descriptors

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: fix braino during controller list creation
Christian Brauner [Wed, 24 Feb 2021 00:26:22 +0000 (01:26 +0100)]
cgroups: fix braino during controller list creation

Co-mounted controllers are conventionally separated by ",".

Fixes: https://jenkins.linuxcontainers.org/job/lxd-github-commit/1905/arch=amd64,backend=dir,compiler=golang-1.15/consoleFull
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: remove faulty use of access attribute
Christian Brauner [Wed, 24 Feb 2021 00:01:17 +0000 (01:01 +0100)]
commands: remove faulty use of access attribute

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3691 from brauner/2021-02-23/fixes
Stéphane Graber [Tue, 23 Feb 2021 21:53:23 +0000 (16:53 -0500)]
Merge pull request #3691 from brauner/2021-02-23/fixes

Fix issues reported by Coverity

3 years agocgroups: fix error checking
Christian Brauner [Tue, 23 Feb 2021 21:10:56 +0000 (22:10 +0100)]
cgroups: fix error checking

Fixes: Coverity 1473310
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoaf_unix: prevent oob writes
Christian Brauner [Tue, 23 Feb 2021 21:08:48 +0000 (22:08 +0100)]
af_unix: prevent oob writes

Fixes: Coverity 1473309
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: only deref once
Christian Brauner [Tue, 23 Feb 2021 21:07:11 +0000 (22:07 +0100)]
commands: only deref once

Fixes: Coverity 1473308
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3690 from brauner/2021-02-21/fixes
Stéphane Graber [Tue, 23 Feb 2021 20:49:38 +0000 (15:49 -0500)]
Merge pull request #3690 from brauner/2021-02-21/fixes

attach: improve attaching of new clients to old servers

3 years agocommands: handle old clients for LXC_CMD_GET_CGROUP_CTX
Christian Brauner [Tue, 23 Feb 2021 20:06:56 +0000 (21:06 +0100)]
commands: handle old clients for LXC_CMD_GET_CGROUP_CTX

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: handle new and old clients
Christian Brauner [Tue, 23 Feb 2021 20:04:41 +0000 (21:04 +0100)]
attach: handle new and old clients

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: make fd sending more uniform
Christian Brauner [Tue, 23 Feb 2021 20:00:22 +0000 (21:00 +0100)]
attach: make fd sending more uniform

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoterminal: dumb logging down
Christian Brauner [Tue, 23 Feb 2021 19:48:53 +0000 (20:48 +0100)]
terminal: dumb logging down

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3689 from brauner/2021-02-21/fixes
Stéphane Graber [Tue, 23 Feb 2021 20:08:04 +0000 (15:08 -0500)]
Merge pull request #3689 from brauner/2021-02-21/fixes

cgroups: introduce fd-only cgroup attach via LXC_CMD_GET_CGROUP_CTX

3 years agoattach: fix namespace preservation
Christian Brauner [Tue, 23 Feb 2021 19:13:29 +0000 (20:13 +0100)]
attach: fix namespace preservation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: verify expected file descriptors were sent
Christian Brauner [Tue, 23 Feb 2021 18:31:29 +0000 (19:31 +0100)]
commands: verify expected file descriptors were sent

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: handle older clients gracefully
Christian Brauner [Tue, 23 Feb 2021 18:10:38 +0000 (19:10 +0100)]
commands: handle older clients gracefully

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: remove additional newline
Christian Brauner [Tue, 23 Feb 2021 18:05:09 +0000 (19:05 +0100)]
attach: remove additional newline

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoaf_unix: add comment about cast
Christian Brauner [Tue, 23 Feb 2021 18:00:42 +0000 (19:00 +0100)]
af_unix: add comment about cast

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: fix unsupported namespaces
Christian Brauner [Tue, 23 Feb 2021 17:59:07 +0000 (18:59 +0100)]
attach: fix unsupported namespaces

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: lxc_cmd_add_state_client_callback()
Christian Brauner [Tue, 23 Feb 2021 15:21:55 +0000 (16:21 +0100)]
commands: lxc_cmd_add_state_client_callback()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: handle older clients elegantly
Christian Brauner [Tue, 23 Feb 2021 14:06:33 +0000 (15:06 +0100)]
commands: handle older clients elegantly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: send ENOSYS response
Christian Brauner [Tue, 23 Feb 2021 13:22:22 +0000 (14:22 +0100)]
commands: send ENOSYS response

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: introduce fd-only cgroup attach
Christian Brauner [Tue, 23 Feb 2021 13:01:59 +0000 (14:01 +0100)]
cgroups: introduce fd-only cgroup attach

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: introduce LXC_CMD_GET_CGROUP_CTX
Christian Brauner [Tue, 23 Feb 2021 13:00:54 +0000 (14:00 +0100)]
commands: introduce LXC_CMD_GET_CGROUP_CTX

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoutils: add copy_struct_to_client()
Christian Brauner [Tue, 23 Feb 2021 12:58:39 +0000 (13:58 +0100)]
utils: add copy_struct_to_client()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolog: add syswarn_set()
Christian Brauner [Tue, 23 Feb 2021 12:58:13 +0000 (13:58 +0100)]
log: add syswarn_set()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoutils: add copy_struct_from_client()
Christian Brauner [Tue, 23 Feb 2021 07:45:32 +0000 (08:45 +0100)]
utils: add copy_struct_from_client()

Which is our variant of copy_struct_from_user() that Aleksa and I added to the
kernel.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agomacro: add min() macro
Christian Brauner [Tue, 23 Feb 2021 07:45:21 +0000 (08:45 +0100)]
macro: add min() macro

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: allow cgroup fd batch retrieval
Christian Brauner [Mon, 22 Feb 2021 21:45:36 +0000 (22:45 +0100)]
cgroups: allow cgroup fd batch retrieval

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: add LXC_CMD_GET_CGROUP_FD
Christian Brauner [Mon, 22 Feb 2021 19:00:18 +0000 (20:00 +0100)]
commands: add LXC_CMD_GET_CGROUP_FD

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: introduce rsp_many_fds()
Christian Brauner [Mon, 22 Feb 2021 20:53:06 +0000 (21:53 +0100)]
commands: introduce rsp_many_fds()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: introduce rsp_one_fd()
Christian Brauner [Mon, 22 Feb 2021 20:51:19 +0000 (21:51 +0100)]
commands: introduce rsp_one_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: introduce lxc_cmd_rsp_send_reap()
Christian Brauner [Mon, 22 Feb 2021 18:01:45 +0000 (19:01 +0100)]
commands: introduce lxc_cmd_rsp_send_reap()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: be more explicit during command processing
Christian Brauner [Mon, 22 Feb 2021 17:24:49 +0000 (18:24 +0100)]
commands: be more explicit during command processing

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agostate: _never_ return NULL from lxc_state2str()
Christian Brauner [Mon, 22 Feb 2021 14:28:07 +0000 (15:28 +0100)]
state: _never_ return NULL from lxc_state2str()

Cc: Thomas Parrott <thomas.parrott@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: add cgroup_fds() helper
Christian Brauner [Mon, 22 Feb 2021 12:00:16 +0000 (13:00 +0100)]
cgroups: add cgroup_fds() helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoaf_unix: improve SCM_RIGHTS file descriptor retrieval
Christian Brauner [Mon, 22 Feb 2021 11:39:13 +0000 (12:39 +0100)]
af_unix: improve SCM_RIGHTS file descriptor retrieval

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: tweak validate_string_request()
Christian Brauner [Mon, 22 Feb 2021 11:25:52 +0000 (12:25 +0100)]
commands: tweak validate_string_request()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: explicitly number enums
Christian Brauner [Mon, 22 Feb 2021 11:12:32 +0000 (12:12 +0100)]
commands: explicitly number enums

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: close dfd_mon but keep dfd_con and dfd_lim open for all cgroup hierarchies
Christian Brauner [Sun, 21 Feb 2021 19:03:45 +0000 (20:03 +0100)]
cgroups: close dfd_mon but keep dfd_con and dfd_lim open for all cgroup hierarchies

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: start stashing all fds
Christian Brauner [Sun, 21 Feb 2021 18:59:25 +0000 (19:59 +0100)]
cgroups: start stashing all fds

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: skip and warn about invalid file descriptors
Christian Brauner [Sun, 21 Feb 2021 18:57:31 +0000 (19:57 +0100)]
cgroups: skip and warn about invalid file descriptors

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agomemory_utils: fix close_equal()
Christian Brauner [Sun, 21 Feb 2021 18:48:11 +0000 (19:48 +0100)]
memory_utils: fix close_equal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoMerge pull request #3688 from brauner/2021-02-19/fixes_2
Stéphane Graber [Mon, 22 Feb 2021 19:52:25 +0000 (14:52 -0500)]
Merge pull request #3688 from brauner/2021-02-19/fixes_2

cgroups: rework cgroup initialization

3 years agocgroups: handle lxc.cgroup.use global parameter
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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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

3 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

3 years agodoc: tweak cgroup headline
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>
3 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>
3 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>
3 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>
3 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>
3 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>