]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
4 years agoutils: check for snprintf() error 3655/head
Christian Brauner [Thu, 4 Feb 2021 21:48:18 +0000 (22:48 +0100)] 
utils: check for snprintf() error

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: improve logging and terminology
Christian Brauner [Thu, 4 Feb 2021 21:42:58 +0000 (22:42 +0100)] 
attach: improve logging and terminology

The term "intermediate process" is not very nice imho, "transient process" fits
better.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3651 from brauner/2021-02-04/fixes
Stéphane Graber [Thu, 4 Feb 2021 20:40:31 +0000 (15:40 -0500)] 
Merge pull request #3651 from brauner/2021-02-04/fixes

cgroups: fix cgroup mounting

4 years agocgroups: check for correct error in __cg_unified_attach() from cgroup_attach() 3651/head
Christian Brauner [Thu, 4 Feb 2021 19:27:40 +0000 (20:27 +0100)] 
cgroups: check for correct error in __cg_unified_attach() from cgroup_attach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: s/dfd_root_host/dfd_host/g
Christian Brauner [Thu, 4 Feb 2021 18:06:38 +0000 (19:06 +0100)] 
tree-wide: s/dfd_root_host/dfd_host/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: s/mntpt_fd/dfd_mnt/g
Christian Brauner [Thu, 4 Feb 2021 18:05:55 +0000 (19:05 +0100)] 
tree-wide: s/mntpt_fd/dfd_mnt/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: s/dev_mntpt_fd/dfd_dev/g
Christian Brauner [Thu, 4 Feb 2021 18:05:05 +0000 (19:05 +0100)] 
tree-wide: s/dev_mntpt_fd/dfd_dev/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosyscall_wrappers: fix PROTECT_OPEN_W macro
Christian Brauner [Thu, 4 Feb 2021 15:06:43 +0000 (16:06 +0100)] 
syscall_wrappers: fix PROTECT_OPEN_W macro

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: restricted fd-only lxc_fill_autodev()
Christian Brauner [Thu, 4 Feb 2021 14:57:13 +0000 (15:57 +0100)] 
conf: restricted fd-only lxc_fill_autodev()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: start stashing dfd to host's / during container setup
Christian Brauner [Thu, 4 Feb 2021 14:56:37 +0000 (15:56 +0100)] 
conf: start stashing dfd to host's / during container setup

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: fix lxc_setup_dev_console()
Christian Brauner [Thu, 4 Feb 2021 14:52:54 +0000 (15:52 +0100)] 
conf: fix lxc_setup_dev_console()

We were printing garbage on accident.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoutils: add mount_from_at()
Christian Brauner [Thu, 4 Feb 2021 14:23:55 +0000 (15:23 +0100)] 
utils: add mount_from_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: restrict open calls in cgroup_attach_create_leaf()
Christian Brauner [Thu, 4 Feb 2021 14:05:43 +0000 (15:05 +0100)] 
cgroups: restrict open calls in cgroup_attach_create_leaf()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: improve error handling and logging in cgroup_attach_leaf()
Christian Brauner [Thu, 4 Feb 2021 14:02:14 +0000 (15:02 +0100)] 
cgroups: improve error handling and logging in cgroup_attach_leaf()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: fix argument vetting in cgroup_attach()
Christian Brauner [Thu, 4 Feb 2021 14:01:45 +0000 (15:01 +0100)] 
cgroups: fix argument vetting in cgroup_attach()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach: fix fallback logic when attaching to cgroups
Christian Brauner [Thu, 4 Feb 2021 14:01:09 +0000 (15:01 +0100)] 
attach: fix fallback logic when attaching to cgroups

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: switch to fd-based cgroup mounting
Christian Brauner [Thu, 4 Feb 2021 13:00:18 +0000 (14:00 +0100)] 
cgroups: switch to fd-based cgroup mounting

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: restricted fd-only controller mountpoint creation
Christian Brauner [Thu, 4 Feb 2021 11:50:43 +0000 (12:50 +0100)] 
cgroups: restricted fd-only controller mountpoint creation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: fix cgroup mounting
Christian Brauner [Thu, 4 Feb 2021 10:22:26 +0000 (11:22 +0100)] 
cgroups: fix cgroup mounting

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3650 from brauner/2021-02-03/fixes_1
Stéphane Graber [Wed, 3 Feb 2021 22:05:35 +0000 (17:05 -0500)] 
Merge pull request #3650 from brauner/2021-02-03/fixes_1

conf: harden various mount paths

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