]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
4 years agoutils: harden __safe_mount_beneath_at() 3650/head
Christian Brauner [Wed, 3 Feb 2021 20:57:44 +0000 (21:57 +0100)] 
utils: harden __safe_mount_beneath_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: refactor transient procfs mounting
Christian Brauner [Wed, 3 Feb 2021 20:31:03 +0000 (21:31 +0100)] 
conf: refactor transient procfs mounting

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: restrict open call in lxc_mount_rootfs()
Christian Brauner [Wed, 3 Feb 2021 19:58:45 +0000 (20:58 +0100)] 
conf: restrict open call in lxc_mount_rootfs()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: make lxc_create_tmp_proc_mount() static
Christian Brauner [Wed, 3 Feb 2021 19:55:01 +0000 (20:55 +0100)] 
conf: make lxc_create_tmp_proc_mount() static

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: coding style
Christian Brauner [Wed, 3 Feb 2021 19:51:56 +0000 (20:51 +0100)] 
conf: coding style

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3648 from brauner/2021-02-03/fixes
Stéphane Graber [Wed, 3 Feb 2021 15:38:50 +0000 (10:38 -0500)] 
Merge pull request #3648 from brauner/2021-02-03/fixes

conf: open hardening & fd-only operations

4 years agoMerge pull request #3649 from brauner/2021-02-03/attach_via_pidfds
Stéphane Graber [Wed, 3 Feb 2021 15:23:53 +0000 (10:23 -0500)] 
Merge pull request #3649 from brauner/2021-02-03/attach_via_pidfds

attach: attach to namespaces via pidfds

4 years agoattach: attach to namespaces via pidfds 3649/head
Christian Brauner [Wed, 3 Feb 2021 14:12:37 +0000 (15:12 +0100)] 
attach: attach to namespaces via pidfds

This is a feature we've enabled in kernel v5.8 and v5.9.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: fd-only devtps setup 3648/head
Christian Brauner [Wed, 3 Feb 2021 10:27:53 +0000 (11:27 +0100)] 
conf: fd-only devtps setup

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: fd-only pivot root
Christian Brauner [Wed, 3 Feb 2021 10:18:04 +0000 (11:18 +0100)] 
conf: fd-only pivot root

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: restrict open for lxc_mount_rootfs()
Christian Brauner [Wed, 3 Feb 2021 09:58:35 +0000 (10:58 +0100)] 
conf: restrict open for lxc_mount_rootfs()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: fd-only operations in lxc_setup_dev_symlinks()
Christian Brauner [Wed, 3 Feb 2021 09:48:12 +0000 (10:48 +0100)] 
conf: fd-only operations in lxc_setup_dev_symlinks()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: harden open in lxc_fill_autodev()
Christian Brauner [Wed, 3 Feb 2021 09:35:16 +0000 (10:35 +0100)] 
conf: harden open in lxc_fill_autodev()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: restrict open of dev/
Christian Brauner [Wed, 3 Feb 2021 09:55:48 +0000 (10:55 +0100)] 
conf: restrict open of dev/

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: remove unnecessary syscall
Christian Brauner [Wed, 3 Feb 2021 09:04:59 +0000 (10:04 +0100)] 
conf: remove unnecessary syscall

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agorexec: mark all fds as close-on-exec if possible
Christian Brauner [Wed, 3 Feb 2021 08:48:25 +0000 (09:48 +0100)] 
rexec: mark all fds as close-on-exec if possible

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosyscalls: add close_range()
Christian Brauner [Wed, 3 Feb 2021 08:45:30 +0000 (09:45 +0100)] 
syscalls: add close_range()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agorexec: check lseek() return value
Christian Brauner [Wed, 3 Feb 2021 08:39:21 +0000 (09:39 +0100)] 
rexec: check lseek() return value

Not really needed buy ok.

Fixes: Coverity: 1472769
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: check for NULL in device_add_remove
Christian Brauner [Wed, 3 Feb 2021 08:36:23 +0000 (09:36 +0100)] 
tests: check for NULL in device_add_remove

Fixes: Coverity 1472768
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3647 from brauner/2021-02-02/fixes
Stéphane Graber [Tue, 2 Feb 2021 23:30:27 +0000 (18:30 -0500)] 
Merge pull request #3647 from brauner/2021-02-02/fixes

cgroup2: only rely on command socket when getting cgroup values

4 years agocgroups: improve parameter vetting 3647/head
Christian Brauner [Tue, 2 Feb 2021 23:00:50 +0000 (00:00 +0100)] 
cgroups: improve parameter vetting

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: support pure unified cgroup layouts in cgpath test
Christian Brauner [Tue, 2 Feb 2021 22:52:18 +0000 (23:52 +0100)] 
tests: support pure unified cgroup layouts in cgpath test

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotest: add logging to device_add_remove
Christian Brauner [Tue, 2 Feb 2021 22:30:00 +0000 (23:30 +0100)] 
test: add logging to device_add_remove

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofreezer: remove lxc_cmd_freeze() and lxc_cmd_unfreeze() calls
Christian Brauner [Tue, 2 Feb 2021 22:24:28 +0000 (23:24 +0100)] 
freezer: remove lxc_cmd_freeze() and lxc_cmd_unfreeze() calls

We're now handling them better.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: use __cgroup_unfreeze() directly
Christian Brauner [Tue, 2 Feb 2021 22:20:07 +0000 (23:20 +0100)] 
commands: use __cgroup_unfreeze() directly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: export __cgroup_unfreeze() for use in commands
Christian Brauner [Tue, 2 Feb 2021 22:19:23 +0000 (23:19 +0100)] 
cgroups: export __cgroup_unfreeze() for use in commands

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: use lxc_cmd_get_limiting_cgroup2_fd()
Christian Brauner [Tue, 2 Feb 2021 22:08:04 +0000 (23:08 +0100)] 
cgroups: use lxc_cmd_get_limiting_cgroup2_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: add missing lxc_cmd_get_limiting_cgroup2_fd() implementation
Christian Brauner [Tue, 2 Feb 2021 22:05:30 +0000 (23:05 +0100)] 
commands: add missing lxc_cmd_get_limiting_cgroup2_fd() implementation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgpath: add logging
Christian Brauner [Tue, 2 Feb 2021 21:55:52 +0000 (22:55 +0100)] 
cgpath: add logging

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: explicitly close seccomp notifier fd
Christian Brauner [Tue, 2 Feb 2021 21:41:40 +0000 (22:41 +0100)] 
attach: explicitly close seccomp notifier fd

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: switch back to returning ints
Christian Brauner [Tue, 2 Feb 2021 21:28:01 +0000 (22:28 +0100)] 
cgroups: switch back to returning ints

Whick makes for easier error checking and fallback code.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: check for ENOCGROUP2 explicitly
Christian Brauner [Tue, 2 Feb 2021 21:23:45 +0000 (22:23 +0100)] 
attach: check for ENOCGROUP2 explicitly

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: return ENOCGROUP2 from cgroup_attach()
Christian Brauner [Tue, 2 Feb 2021 21:22:53 +0000 (22:22 +0100)] 
cgroups: return ENOCGROUP2 from cgroup_attach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: stricter argument vetting for cgroup_attach()
Christian Brauner [Tue, 2 Feb 2021 21:22:25 +0000 (22:22 +0100)] 
cgroups: stricter argument vetting for cgroup_attach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: move down cgroup_attach()
Christian Brauner [Tue, 2 Feb 2021 21:21:38 +0000 (22:21 +0100)] 
cgroups: move down cgroup_attach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxccontainer: use correct error checks
Christian Brauner [Tue, 2 Feb 2021 21:15:43 +0000 (22:15 +0100)] 
lxccontainer: use correct error checks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: vet parameters
Christian Brauner [Tue, 2 Feb 2021 20:59:04 +0000 (21:59 +0100)] 
cgroups: vet parameters

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: remove unused conf argument
Christian Brauner [Tue, 2 Feb 2021 20:56:32 +0000 (21:56 +0100)] 
cgroups: remove unused conf argument

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: rewind() file before polling again
Christian Brauner [Tue, 2 Feb 2021 18:29:41 +0000 (19:29 +0100)] 
cgroups: rewind() file before polling again

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxccontainer: use cgroup_freeze() and cgroup_unfreeze()
Christian Brauner [Tue, 2 Feb 2021 17:31:52 +0000 (18:31 +0100)] 
lxccontainer: use cgroup_freeze() and cgroup_unfreeze()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofreezer: make methods return bool
Christian Brauner [Tue, 2 Feb 2021 17:55:39 +0000 (18:55 +0100)] 
freezer: make methods return bool

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: add cgroup_freeze() and cgroup_unfreeze()
Christian Brauner [Tue, 2 Feb 2021 17:27:12 +0000 (18:27 +0100)] 
cgroups: add cgroup_freeze() and cgroup_unfreeze()

These are unified hierarchy only methods which don't need to initialize a full
cgroup driver. Instead, they rely on the command socket to retrieve a cgroup2
file descriptor to the container's cgroup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofreezer: use lxc_cmd_notify_state_listeners()
Christian Brauner [Tue, 2 Feb 2021 17:26:57 +0000 (18:26 +0100)] 
freezer: use lxc_cmd_notify_state_listeners()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands_utils: add lcx_cmd_notify_state_listeners()
Christian Brauner [Tue, 2 Feb 2021 17:26:29 +0000 (18:26 +0100)] 
commands_utils: add lcx_cmd_notify_state_listeners()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: annotate cgroup_get()/cgroup_set()
Christian Brauner [Tue, 2 Feb 2021 17:09:29 +0000 (18:09 +0100)] 
cgroups: annotate cgroup_get()/cgroup_set()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: move functions after methods
Christian Brauner [Tue, 2 Feb 2021 17:08:14 +0000 (18:08 +0100)] 
cgroups: move functions after methods

This makes it more obvious that they are separate.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxccontainer: use cgroup_set()
Christian Brauner [Tue, 2 Feb 2021 17:03:41 +0000 (18:03 +0100)] 
lxccontainer: use cgroup_set()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxccontainer: use correct variable ordering
Christian Brauner [Tue, 2 Feb 2021 17:02:47 +0000 (18:02 +0100)] 
lxccontainer: use correct variable ordering

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: add croup_set()
Christian Brauner [Tue, 2 Feb 2021 16:40:30 +0000 (17:40 +0100)] 
cgroups: add croup_set()

This is a unified hierarchy only method which doesn't need to initialize a full
cgroup driver. Instead, it relies on the command socket to retrieve a cgroup2
file descriptor to the container's cgroup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: reorder cgroup_get() arguments
Christian Brauner [Tue, 2 Feb 2021 16:40:08 +0000 (17:40 +0100)] 
cgroups: reorder cgroup_get() arguments

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxccontainer: use cgroup_get()
Christian Brauner [Tue, 2 Feb 2021 16:00:49 +0000 (17:00 +0100)] 
lxccontainer: use cgroup_get()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: add cgroup_get()
Christian Brauner [Tue, 2 Feb 2021 15:59:38 +0000 (16:59 +0100)] 
cgroups: add cgroup_get()

This is a unified hierarchy only method which doesn't need to initialize a full
cgroup driver. Instead, it relies on the command socket to retrieve a cgroup2
file descriptor to the container's cgroup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: add lxc_read_try_buf_at()
Christian Brauner [Tue, 2 Feb 2021 15:59:14 +0000 (16:59 +0100)] 
file_utils: add lxc_read_try_buf_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomacro: abuse ENOMEDIUM as ENOCGROUP2
Christian Brauner [Tue, 2 Feb 2021 15:58:45 +0000 (16:58 +0100)] 
macro: abuse ENOMEDIUM as ENOCGROUP2

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3646 from brauner/2021-02-02/fixes
Stéphane Graber [Tue, 2 Feb 2021 14:28:50 +0000 (09:28 -0500)] 
Merge pull request #3646 from brauner/2021-02-02/fixes

attach & cgroup hardening

4 years agocgroups: switch controller delegation to fd-only operations 3646/head
Christian Brauner [Tue, 2 Feb 2021 12:47:40 +0000 (13:47 +0100)] 
cgroups: switch controller delegation to fd-only operations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: add unified_cgroup_fd() helper
Christian Brauner [Tue, 2 Feb 2021 12:46:03 +0000 (13:46 +0100)] 
cgroups: add unified_cgroup_fd() helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: harden lxc_writeat()
Christian Brauner [Tue, 2 Feb 2021 12:45:26 +0000 (13:45 +0100)] 
file_utils: harden lxc_writeat()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: harden lxc_open_dirfd()
Christian Brauner [Tue, 2 Feb 2021 12:45:11 +0000 (13:45 +0100)] 
file_utils: harden lxc_open_dirfd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosyscall_wrappers: add PROTECT_OPEN_W_* variants
Christian Brauner [Tue, 2 Feb 2021 12:44:37 +0000 (13:44 +0100)] 
syscall_wrappers: add PROTECT_OPEN_W_* variants

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomemory_utils: add close_prot_errno_mov()
Christian Brauner [Tue, 2 Feb 2021 12:44:13 +0000 (13:44 +0100)] 
memory_utils: add close_prot_errno_mov()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: move loading seccomp as late as possible
Christian Brauner [Tue, 2 Feb 2021 09:43:12 +0000 (10:43 +0100)] 
attach: move loading seccomp as late as possible

We want to minimize the change that the profile blocks syscalls we need during
attach setup and has the notifier enabled.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: move file descriptor closing into attach_context_container()
Christian Brauner [Tue, 2 Feb 2021 09:26:21 +0000 (10:26 +0100)] 
attach: move file descriptor closing into attach_context_container()

This reduces the possibility of forgetting to close the namespace file
descriptors when we change this codepath.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: stricter lookup semantics for fdopen_at() calls
Christian Brauner [Tue, 2 Feb 2021 08:54:10 +0000 (09:54 +0100)] 
attach: stricter lookup semantics for fdopen_at() calls

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3645 from brauner/2021-02-01/fixes_4
Stéphane Graber [Mon, 1 Feb 2021 22:13:37 +0000 (17:13 -0500)] 
Merge pull request #3645 from brauner/2021-02-01/fixes_4

attach: bugfixes

4 years agoconfile_utils: use lxc_log_trace() 3645/head
Christian Brauner [Mon, 1 Feb 2021 21:54:47 +0000 (22:54 +0100)] 
confile_utils: use lxc_log_trace()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use lxc_log_trace()
Christian Brauner [Mon, 1 Feb 2021 21:53:56 +0000 (22:53 +0100)] 
conf: use lxc_log_trace()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands_utils: don't leak memory
Christian Brauner [Mon, 1 Feb 2021 21:34:33 +0000 (22:34 +0100)] 
commands_utils: don't leak memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: use correct put method
Christian Brauner [Mon, 1 Feb 2021 21:13:03 +0000 (22:13 +0100)] 
attach: use correct put method

Fixes: Coverity 1472763
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: prevent UAF
Christian Brauner [Mon, 1 Feb 2021 21:11:38 +0000 (22:11 +0100)] 
attach: prevent UAF

Fixes: Coverity 1472761
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3644 from brauner/2021-02-01/fixes_3
Stéphane Graber [Mon, 1 Feb 2021 20:26:08 +0000 (15:26 -0500)] 
Merge pull request #3644 from brauner/2021-02-01/fixes_3

attach: harden open() calls

4 years agoattach: file descriptor based fdinfo handling 3644/head
Christian Brauner [Mon, 1 Feb 2021 19:25:51 +0000 (20:25 +0100)] 
attach: file descriptor based fdinfo handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: remove O_NOFOLLOW from open_at() defaults
Christian Brauner [Mon, 1 Feb 2021 19:17:16 +0000 (20:17 +0100)] 
file_utils: remove O_NOFOLLOW from open_at() defaults

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolsm: harden read_file_at()
Christian Brauner [Mon, 1 Feb 2021 19:15:16 +0000 (20:15 +0100)] 
lsm: harden read_file_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: extend read_file_at()
Christian Brauner [Mon, 1 Feb 2021 19:12:03 +0000 (20:12 +0100)] 
tree-wide: extend read_file_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: harden open calls
Christian Brauner [Mon, 1 Feb 2021 19:03:29 +0000 (20:03 +0100)] 
attach: harden open calls

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosyscall_wrappers: add PROTECT_LOOKUP, PROTECT_OPEN, PROTECT_LOOKUP_WITH_SYMLINKS...
Christian Brauner [Mon, 1 Feb 2021 16:08:06 +0000 (17:08 +0100)] 
syscall_wrappers: add PROTECT_LOOKUP, PROTECT_OPEN, PROTECT_LOOKUP_WITH_SYMLINKS, PROTECT_OPEN_WITH_TRAILING_SYMLINKS

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: add open_at()
Christian Brauner [Mon, 1 Feb 2021 16:03:59 +0000 (17:03 +0100)] 
file_utils: add open_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3642 from brauner/2021-02-01/fixes
Stéphane Graber [Mon, 1 Feb 2021 15:17:18 +0000 (10:17 -0500)] 
Merge pull request #3642 from brauner/2021-02-01/fixes

attach: rework id handling

4 years agoMerge pull request #3643 from brauner/2021-02-01/fixes_2
Stéphane Graber [Mon, 1 Feb 2021 15:14:49 +0000 (10:14 -0500)] 
Merge pull request #3643 from brauner/2021-02-01/fixes_2

cgroups: remove pointless NULL checks

4 years agocgroups: initialize variable 3643/head
Christian Brauner [Mon, 1 Feb 2021 14:44:59 +0000 (15:44 +0100)] 
cgroups: initialize variable

Fixes: Coverity 1472651
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: remove pointless NULL checks
Christian Brauner [Mon, 1 Feb 2021 14:20:43 +0000 (15:20 +0100)] 
cgroups: remove pointless NULL checks

We're already ensuring before that conf isn't NULL.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: stash host uid and host gid in attach_context 3642/head
Christian Brauner [Mon, 1 Feb 2021 14:16:56 +0000 (15:16 +0100)] 
attach: stash host uid and host gid in attach_context

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: fix error checking for dup2()
Christian Brauner [Mon, 1 Feb 2021 13:51:41 +0000 (14:51 +0100)] 
attach: fix error checking for dup2()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: fix logging for stdfd replacement
Christian Brauner [Mon, 1 Feb 2021 13:50:55 +0000 (14:50 +0100)] 
attach: fix logging for stdfd replacement

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: log failues to dup2() with SYSDEBUG()
Christian Brauner [Mon, 1 Feb 2021 13:44:45 +0000 (14:44 +0100)] 
attach: log failues to dup2() with SYSDEBUG()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoutils: use SYSTRACE() when logging stdio permission fixup failures
Christian Brauner [Mon, 1 Feb 2021 13:35:42 +0000 (14:35 +0100)] 
utils: use SYSTRACE() when logging stdio permission fixup failures

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: document attach_context
Christian Brauner [Mon, 1 Feb 2021 11:23:43 +0000 (12:23 +0100)] 
attach: document attach_context

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: simplify opening of /proc/self
Christian Brauner [Mon, 1 Feb 2021 11:23:26 +0000 (12:23 +0100)] 
attach: simplify opening of /proc/self

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: move uid and gid handling to get_attach_context()
Christian Brauner [Mon, 1 Feb 2021 11:22:42 +0000 (12:22 +0100)] 
attach: move uid and gid handling to get_attach_context()

the less we do in do_attach(), the better.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: initialize init_pid field to -ESRCH
Christian Brauner [Mon, 1 Feb 2021 10:43:47 +0000 (11:43 +0100)] 
attach: initialize init_pid field to -ESRCH

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: unifiy /proc/<init-pid>/status parsing
Christian Brauner [Mon, 1 Feb 2021 10:37:22 +0000 (11:37 +0100)] 
attach: unifiy /proc/<init-pid>/status parsing

and move it out of do_attach(). The less we do in the container's context the
better.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: add fdopenat()
Christian Brauner [Mon, 1 Feb 2021 10:11:15 +0000 (11:11 +0100)] 
file_utils: add fdopenat()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3641 from brauner/2021-01-30/fixes
Stéphane Graber [Sun, 31 Jan 2021 22:13:25 +0000 (17:13 -0500)] 
Merge pull request #3641 from brauner/2021-01-30/fixes

attach: pidfd-based hardening and file-descriptor-only LSM interactions

4 years agolsm/apparmor: cleanup apparmor_process_label_set() 3641/head
Christian Brauner [Sun, 31 Jan 2021 20:48:00 +0000 (21:48 +0100)] 
lsm/apparmor: cleanup apparmor_process_label_set()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: hardening through use of pidfds
Christian Brauner [Sun, 31 Jan 2021 19:44:09 +0000 (20:44 +0100)] 
attach: hardening through use of pidfds

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: file descriptors based LSM handling
Christian Brauner [Sun, 31 Jan 2021 18:26:53 +0000 (19:26 +0100)] 
attach: file descriptors based LSM handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: align methods
Christian Brauner [Sat, 30 Jan 2021 20:54:45 +0000 (21:54 +0100)] 
cgroups: align methods

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3639 from brauner/2021-01-28/fixes
Stéphane Graber [Sat, 30 Jan 2021 19:23:25 +0000 (14:23 -0500)] 
Merge pull request #3639 from brauner/2021-01-28/fixes

cgroups: fixes and improvements

4 years agocgroups: use PTR_TO_U64() 3639/head
Christian Brauner [Sat, 30 Jan 2021 16:28:32 +0000 (17:28 +0100)] 
cgroups: use PTR_TO_U64()

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