]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
3 years agotests: fix config file tests 3969/head
Christian Brauner [Mon, 13 Sep 2021 12:11:05 +0000 (14:11 +0200)] 
tests: fix config file tests

Link: https://bugs.launchpad.net/bugs/1943441
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agodoc/api-extensions: Grammar fix
Stéphane Graber [Mon, 9 Aug 2021 17:18:44 +0000 (13:18 -0400)] 
doc/api-extensions: Grammar fix

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agolsm/apparmor: use cleanup macro
Christian Brauner [Mon, 9 Aug 2021 13:59:26 +0000 (15:59 +0200)] 
lsm/apparmor: use cleanup macro

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolsm/apparmor: log failure to write AppArmor profile
Christian Brauner [Mon, 9 Aug 2021 13:58:53 +0000 (15:58 +0200)] 
lsm/apparmor: log failure to write AppArmor profile

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: fix container with empty network namespaces
Christian Brauner [Thu, 5 Aug 2021 14:16:33 +0000 (16:16 +0200)] 
network: fix container with empty network namespaces

Fixes: #3922
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: add test for rootfs mount options
Christian Brauner [Tue, 3 Aug 2021 12:40:28 +0000 (14:40 +0200)] 
tests: add test for rootfs mount options

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: allow mount options for rootfs when using new mount api
Christian Brauner [Tue, 3 Aug 2021 11:16:45 +0000 (13:16 +0200)] 
conf: allow mount options for rootfs when using new mount api

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomount_utils: make some mount helpers static inline
Christian Brauner [Tue, 3 Aug 2021 10:51:24 +0000 (12:51 +0200)] 
mount_utils: make some mount helpers static inline

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: let parse_vfs_attr() handle legacy mount flags as well
Christian Brauner [Tue, 3 Aug 2021 10:13:01 +0000 (12:13 +0200)] 
conf: let parse_vfs_attr() handle legacy mount flags as well

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: log failure to create tty mountpoint
Christian Brauner [Tue, 3 Aug 2021 07:22:46 +0000 (09:22 +0200)] 
conf: log failure to create tty mountpoint

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: refactor lxc_recv_ttys_from_child()
Christian Brauner [Mon, 2 Aug 2021 17:16:54 +0000 (19:16 +0200)] 
conf: refactor lxc_recv_ttys_from_child()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: fix logging in lxc_idmapped_mounts_child()
Christian Brauner [Mon, 2 Aug 2021 16:47:44 +0000 (18:47 +0200)] 
conf: fix logging in lxc_idmapped_mounts_child()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomount_utils: introduce mount_at()
Christian Brauner [Mon, 2 Aug 2021 13:30:03 +0000 (15:30 +0200)] 
mount_utils: introduce mount_at()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: fail on unknown error during TIOCGPTPEER
Christian Brauner [Sat, 31 Jul 2021 08:19:57 +0000 (10:19 +0200)] 
terminal: fail on unknown error during TIOCGPTPEER

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: move native terminal allocation from error logging to info
Christian Brauner [Sat, 31 Jul 2021 08:17:36 +0000 (10:17 +0200)] 
terminal: move native terminal allocation from error logging to info

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: handle kernels without TIOCGPTPEER
Christian Brauner [Sat, 31 Jul 2021 08:14:39 +0000 (10:14 +0200)] 
conf: handle kernels without TIOCGPTPEER

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostart: allow containers to use a native console
Christian Brauner [Fri, 30 Jul 2021 12:28:17 +0000 (14:28 +0200)] 
start: allow containers to use a native console

After all of the previous rework we can make it possible for a container
to use a console allocated from the container's devpts instance.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: remove unused argument from lxc_devpts_terminal()
Christian Brauner [Fri, 30 Jul 2021 11:49:15 +0000 (13:49 +0200)] 
terminal: remove unused argument from lxc_devpts_terminal()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: rework console setup
Christian Brauner [Fri, 30 Jul 2021 11:13:28 +0000 (13:13 +0200)] 
conf: rework console setup

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agofile_utils: add open_at_same()
Christian Brauner [Fri, 30 Jul 2021 11:02:01 +0000 (13:02 +0200)] 
file_utils: add open_at_same()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use mount_fd() during console mounting
Christian Brauner [Fri, 30 Jul 2021 07:40:40 +0000 (09:40 +0200)] 
conf: use mount_fd() during console mounting

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use mount_fd() in lxc_setup_dev_console()
Christian Brauner [Fri, 30 Jul 2021 07:27:54 +0000 (09:27 +0200)] 
conf: use mount_fd() in lxc_setup_dev_console()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use mount_fd() helper when mounting ttys
Christian Brauner [Fri, 30 Jul 2021 07:20:22 +0000 (09:20 +0200)] 
conf: use mount_fd() helper when mounting ttys

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agomount_utils: add mount_fd()
Christian Brauner [Fri, 30 Jul 2021 07:15:14 +0000 (09:15 +0200)] 
mount_utils: add mount_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: stash pty_nr in struct lxc_terminal
Christian Brauner [Fri, 30 Jul 2021 07:07:50 +0000 (09:07 +0200)] 
conf: stash pty_nr in struct lxc_terminal

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: move lxc_create_ttys() before pivot root
Christian Brauner [Thu, 29 Jul 2021 17:00:32 +0000 (19:00 +0200)] 
conf: move lxc_create_ttys() before pivot root

This is the last setup step that occured after pivot root.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: split out lxc_devpts_terminal() helper
Christian Brauner [Thu, 29 Jul 2021 16:39:26 +0000 (18:39 +0200)] 
terminal: split out lxc_devpts_terminal() helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostring_utils: cast __s64 to long long signed int
Christian Brauner [Thu, 29 Jul 2021 16:25:19 +0000 (18:25 +0200)] 
string_utils: cast __s64 to long long signed int

Link: https://launchpadlibrarian.net/550723147/buildlog_snap_ubuntu_focal_ppc64el_lxd-latest-edge_BUILDING.txt.gz
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: merge devpts setup and move before pivot root
Christian Brauner [Thu, 29 Jul 2021 13:52:52 +0000 (15:52 +0200)] 
conf: merge devpts setup and move before pivot root

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: don't use ttyname_r() for native terminal allocation
Christian Brauner [Thu, 29 Jul 2021 13:46:17 +0000 (15:46 +0200)] 
terminal: don't use ttyname_r() for native terminal allocation

Since we can call that function from another mount namespace we need to
do this manually.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: add and use mount_beneath_fd()
Christian Brauner [Thu, 29 Jul 2021 12:32:21 +0000 (14:32 +0200)] 
conf: add and use mount_beneath_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: update comment
Christian Brauner [Thu, 29 Jul 2021 12:16:39 +0000 (14:16 +0200)] 
conf: update comment

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use a relative path in symlinkat()
Christian Brauner [Thu, 29 Jul 2021 12:15:51 +0000 (14:15 +0200)] 
conf: use a relative path in symlinkat()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: s/lxc_setup_devpts_parent/lxc_recv_devpts_from_child/g
Christian Brauner [Thu, 29 Jul 2021 09:00:51 +0000 (11:00 +0200)] 
conf: s/lxc_setup_devpts_parent/lxc_recv_devpts_from_child/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: attach devpts mount directly when new mount api can be used
Christian Brauner [Thu, 29 Jul 2021 08:46:59 +0000 (10:46 +0200)] 
conf: attach devpts mount directly when new mount api can be used

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: set source property for devpts
Christian Brauner [Thu, 29 Jul 2021 13:39:04 +0000 (15:39 +0200)] 
conf: set source property for devpts

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: surface failures to setup console
Christian Brauner [Thu, 29 Jul 2021 13:26:17 +0000 (15:26 +0200)] 
conf: surface failures to setup console

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoFix typos
Stéphane Graber [Wed, 28 Jul 2021 19:13:52 +0000 (15:13 -0400)] 
Fix typos

This fixes all typos identified by lintian.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoconf: ensure devpts_fd is set to -EBADF
Christian Brauner [Wed, 28 Jul 2021 16:39:31 +0000 (18:39 +0200)] 
conf: ensure devpts_fd is set to -EBADF

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: ttyname_r() returns an error number on failure
Christian Brauner [Wed, 28 Jul 2021 15:25:38 +0000 (17:25 +0200)] 
terminal: ttyname_r() returns an error number on failure

In other words, how inconsistent can an API be?

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use new mount api for devpts setup
Christian Brauner [Wed, 28 Jul 2021 14:38:36 +0000 (16:38 +0200)] 
conf: use new mount api for devpts setup

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobpf: bpf_devices_cgroup_supported() should check if bpf() is available
Petr Malat [Mon, 19 Jul 2021 10:28:45 +0000 (12:28 +0200)] 
bpf: bpf_devices_cgroup_supported() should check if bpf() is available

bpf_devices_cgroup_supported() tries to load a simple BPF program to
test if BPF works. This is problematic because the function used to load
the program - bpf_program_load_kernel() - emits an error to the log if
BPF is not enabled in the kernel although device controller is not
requested in the configuration. Users could interpret that as a problem.

Make bpf_devices_cgroup_supported() check if the BPF syscall is available
before calling bpf_program_load_kernel(). We can do it by passing a NULL
pointer instead of the syscall argument as the kernel returns either
ENOSYS, when the syscall is not implemented or EFAULT, when it is
implemented.

Signed-off-by: Petr Malat <oss@malat.biz>
4 years agolxc_setup_ttys: Handle existing ttyN file without underlying device
Petr Malat [Mon, 19 Jul 2021 19:51:25 +0000 (21:51 +0200)] 
lxc_setup_ttys: Handle existing ttyN file without underlying device

If a device file is opened and there isn't the underlying device,
the open call fails with ENXIO, but the path can be opened with
O_PATH, which is enough for mounting over the device file.

Generalize this idea and use O_PATH for all cases when the file
is there. One still must check for both ENXIO and EEXIST as it's
unspecified what error is reported if multiple error conditions
occur at the same time.

Signed-off-by: Petr Malat <oss@malat.biz>
4 years agocgroups: remove unneeded variables from cgroup_tree_create
Stoiko Ivanov [Tue, 20 Jul 2021 08:30:36 +0000 (10:30 +0200)] 
cgroups: remove unneeded variables from cgroup_tree_create

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agocgroups: populate hierarchy for device cgroup
Stoiko Ivanov [Mon, 19 Jul 2021 14:55:43 +0000 (16:55 +0200)] 
cgroups: populate hierarchy for device cgroup

With the changes introduced in:
b7b1e3a34ce28b01206c48227930ff83d399e7b6
the hierarchy-struct did not have the path_lim set anymore, which is
needed by setup_limits_legacy (->cg_legacy_set_data->lxc_write_openat)
to actually access the cgroup directory.

The issue can be reproduced with a container config having
```
lxc.cgroup.devices.deny = a
```
(or any lxc.cgroup.devices entry) set on a system booted with
systemd.unified_cgroup_hierarchy=0.

This affects all privileged containers on PVE (due to the default
devices.deny entry).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agoRelease LXC 4.0.10 lxc-4.0.10
Stéphane Graber [Fri, 16 Jul 2021 20:30:14 +0000 (16:30 -0400)] 
Release LXC 4.0.10

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoterminal: fix error handling
Christian Brauner [Thu, 15 Jul 2021 20:09:31 +0000 (22:09 +0200)] 
terminal: fix error handling

Fixes: f382bcc6d820 ("terminal: log TIOCGPTPEER failure less alarmingly")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoaf_unix: report error when no fd is to be sent
Christian Brauner [Thu, 15 Jul 2021 16:47:27 +0000 (18:47 +0200)] 
af_unix: report error when no fd is to be sent

Fixes: #3624
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: log TIOCGPTPEER failure less alarmingly
Christian Brauner [Thu, 15 Jul 2021 16:37:22 +0000 (18:37 +0200)] 
terminal: log TIOCGPTPEER failure less alarmingly

This is not a fatal error and the fallback codepath is equally safe.
When we use TIOCGPTPEER we're using a stashed fd to the container's
devpts mount's ptmx device and allocating a new fd non-path based
through this ioctl. If this ioctl can't be used we're falling back to
allocating a pts device from the host's devpts mount's ptmx device which
is path-based but is not under control of the container and so that's
safe. The difference is just that the first method gets you a nice
native terminal with all the pleasantries of having tty and friends
working whereas the latter method does not.

Fixes: #3625
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosync: fix log message
Christian Brauner [Thu, 15 Jul 2021 16:18:25 +0000 (18:18 +0200)] 
sync: fix log message

Fixes: #3875
Suggested-by: Hank.shi <shk242673@163.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostart: fix logging message
Christian Brauner [Thu, 15 Jul 2021 16:16:39 +0000 (18:16 +0200)] 
start: fix logging message

Fixes: #3875
Suggested-by: Hank.shi <shk242673@163.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoinitutils: include pthread.h
Christian Brauner [Thu, 15 Jul 2021 08:37:47 +0000 (10:37 +0200)] 
initutils: include pthread.h

Otherwise we might end up with implicit function declaration warnings.

Link: https://jenkins.linuxcontainers.org/job/lxc-build-android/8915/console
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agodoc/common_options: add trace and alert loglevels
Serge Hallyn [Thu, 15 Jul 2021 03:17:40 +0000 (22:17 -0500)] 
doc/common_options: add trace and alert loglevels

Signed-off-by: Serge Hallyn <serge@hallyn.com>
4 years agofile_utils: surface ENOENT when falling back to openat()
Christian Brauner [Thu, 8 Jul 2021 12:49:26 +0000 (14:49 +0200)] 
file_utils: surface ENOENT when falling back to openat()

Link: https://discuss.linuxcontainers.org/t/error-failed-to-retrieve-pid-of-executing-child-process
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxc_unshare: fix network device handling
Christian Brauner [Mon, 5 Jul 2021 10:19:31 +0000 (12:19 +0200)] 
lxc_unshare: fix network device handling

We were passing the wrong PID. Fix this!

Link: https://discuss.linuxcontainers.org/t/problem-with-moving-interface-new-network-namespace-in-lxc-unshare
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxc_unshare: make mount table private
Christian Brauner [Mon, 5 Jul 2021 10:11:42 +0000 (12:11 +0200)] 
lxc_unshare: make mount table private

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfile: allow including nonexisting directories
Wolfgang Bumiller [Mon, 5 Jul 2021 08:53:41 +0000 (10:53 +0200)] 
confile: allow including nonexisting directories

If an include directive ends with a trailing slash, we now
always assume it is a directory and do not treat the
non-existence as an error.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agoconf: userns.conf: include userns.conf.d
Wolfgang Bumiller [Mon, 5 Jul 2021 07:02:36 +0000 (09:02 +0200)] 
conf: userns.conf: include userns.conf.d

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agodoc: Fix typo in English lxc.container.conf(5)
KATOH Yasufumi [Mon, 5 Jul 2021 03:00:32 +0000 (12:00 +0900)] 
doc: Fix typo in English lxc.container.conf(5)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
4 years agodoc: Add new idmap= option to Japanese lxc.container.conf(5)
KATOH Yasufumi [Mon, 5 Jul 2021 02:44:30 +0000 (11:44 +0900)] 
doc: Add new idmap= option to Japanese lxc.container.conf(5)

Update for commit 1852be904823e3532af38efc5ef55d3fb931e616

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
4 years agodoc: Append description of net type field
KATOH Yasufumi [Mon, 5 Jul 2021 02:23:49 +0000 (11:23 +0900)] 
doc: Append description of net type field

Update for commit 320061b34fea7d7f280b0a421dddeac7dac7f1bf

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
4 years agodoc: Add eBPF-based device controller semantics to Japanese man page
KATOH Yasufumi [Sun, 27 Jun 2021 15:10:09 +0000 (00:10 +0900)] 
doc: Add eBPF-based device controller semantics to Japanese man page

Update for commit 5025f3a69053bbddbe6c76ffb55b4bbd5759dcc8

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
4 years agocmd/lxc-checkconfig: list cgroup namespaces and rename confusing ns_cgroup entry
Christian Brauner [Thu, 1 Jul 2021 11:39:46 +0000 (13:39 +0200)] 
cmd/lxc-checkconfig: list cgroup namespaces and rename confusing ns_cgroup entry

Link: https://discuss.linuxcontainers.org/t/cgroup-namespace-required-in-lxc-checkconfig-and-config-cgroup-ns
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoterminal: ensure newlines are turned into newlines+carriage return for terminal output
Christian Brauner [Thu, 1 Jul 2021 08:22:56 +0000 (10:22 +0200)] 
terminal: ensure newlines are turned into newlines+carriage return for terminal output

Fixes: #3879
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: handle funky cgroup layouts
Christian Brauner [Thu, 1 Jul 2021 07:51:30 +0000 (09:51 +0200)] 
cgroups: handle funky cgroup layouts

Old versions of Docker emulate a cgroup namespace by bind-mounting the
container's cgroup over the corresponding controller:

/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime master:11 - cgroup cgroup rw,xattr,name=systemd
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/net_cls,net_prio rw,nosuid,nodev,noexec,relatime master:15 - cgroup cgroup rw,net_cls,net_prio
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime master:16 - cgroup cgroup rw,cpu,cpuacct
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime master:17 - cgroup cgroup rw,memory
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime master:18 - cgroup cgroup rw,devices
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime master:19 - cgroup cgroup rw,hugetlb
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime master:20 - cgroup cgroup rw,perf_event
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime master:21 - cgroup cgroup rw,cpuset
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime master:22 - cgroup cgroup rw,blkio
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime master:23 - cgroup cgroup rw,pids
/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod7d4424e6_bb13_42f4_a47a_45a4828bf54d.slice/docker-d0b3604b67ac7930dd34ba3a796627e3e4717d12309e90a4afe3f38b6816ac98.scope /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime master:24 - cgroup cgroup rw,freezer

New versions of LXC always stash a file descriptor for the root of the
cgroup mount at /sys/fs/cgroup and then resolve the current cgroup
parsed from /proc/{1,self}/cgroup relative to that file descriptor. This
doesn't work when the caller's cgroup is mouned over the controllers.
Older versions of LXC simply counted such layouts as having no cgroups
available for delegation at all and moved on provided no cgroup limits
were requested. But mainline LXC would fail such layouts. While I would
argue that failing such layouts is the semantically clean approach we
shouldn't regress users so make mainline LXC treat such cgroup layouts
as having no cgroups available for delegation.

Fixes: #3890
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: add tests for read-only /sys with read-write /sys/devices/virtual/net
Christian Brauner [Wed, 30 Jun 2021 11:41:46 +0000 (13:41 +0200)] 
tests: add tests for read-only /sys with read-write /sys/devices/virtual/net

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: improve read-only /sys with read-write /sys/devices/virtual/net
Christian Brauner [Wed, 30 Jun 2021 11:22:15 +0000 (13:22 +0200)] 
conf: improve read-only /sys with read-write /sys/devices/virtual/net

Some tools require /sys/devices/virtual/net to be read-write. At the
same time we want all other parts of /sys to be read-only. To do this we
created a layout where we hade a read-only instance of sysfs mounted on
top of a read-write instance of sysfs:

`-/sys                                  sysfs                                                        sysfs      rw,nosuid,nodev,noexec,relatime
  `-/sys                                sysfs                                                        sysfs      ro,nosuid,nodev,noexec,relatime
    |-/sys/devices/virtual/net          sysfs                                                        sysfs      rw,relatime
    | `-/sys/devices/virtual/net        sysfs[/devices/virtual/net]                                  sysfs      rw,nosuid,nodev,noexec,relatime

This causes issues for systemd services that create a separate mount
namespace as they get confused to what mount options need to be
respected.

Simplify our mounting logic so we end up with a single read-only mount
of sysfs on /sys and a read-write bind-mount of /sys/devices/virtual/net:

├─/sys                                sysfs                                                                                  sysfs         ro,nosuid,nodev,noexec,relatime
│ ├─/sys/devices/virtual/net          sysfs[/devices/virtual/net]                                                            sysfs         rw,nosuid,nodev,noexec,relatime

Link: systemd/systemd#20032
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoinitutils: close dirfd in error path
Simon Deziel [Tue, 29 Jun 2021 15:50:09 +0000 (11:50 -0400)] 
initutils: close dirfd in error path

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
4 years agoexecute: ensure parent is notified about child exec and close all unneeded fds
Christian Brauner [Tue, 29 Jun 2021 08:32:31 +0000 (10:32 +0200)] 
execute: ensure parent is notified about child exec and close all unneeded fds

lxc_container_init() creates the container payload process as it's child
so lxc_container_init() itself never really exits and thus the parent
isn't notified about the child exec'ing since the sync file descriptor
is never closed. Make sure it's closed to notify the parent about the
child's exec.

In addition we're currently leaking all file descriptors associated with
the handler into the stub init. Make sure that all file descriptors
other than stderr are closed.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agonetwork: log network devices while sending
Christian Brauner [Tue, 29 Jun 2021 08:32:05 +0000 (10:32 +0200)] 
network: log network devices while sending

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoinitutils: use vfork() in lxc_container_init()
Christian Brauner [Tue, 29 Jun 2021 08:31:17 +0000 (10:31 +0200)] 
initutils: use vfork() in lxc_container_init()

We can let the child finish calling exec before continuing in the
parent.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoexecute: don't exec init, call it
Tycho Andersen [Mon, 28 Jun 2021 14:38:48 +0000 (08:38 -0600)] 
execute: don't exec init, call it

Instead of having a statically linked init that we put on the host fs
somewhere via packaging, have to either bind mount in or detect fexecve()
functionality, let's just call it as a library function. This way we don't
have to do any of that.

This also fixes up a bunch of conditions from:

if (quiet)
    fprintf(stderr, "log message");

to

if (!quiet)
    fprintf(stderr, "log message");

:)

and it drops all the code for fexecve() detection and bind mounting our
init in, since we no longer need any of that.

A couple other thoughts:

* I left the lxc-init binary in since we ship it, so someone could be using
  it outside of the internal uses.
* There are lots of unused arguments to lxc-init (including presumably
  --quiet, since nobody noticed the above); those may be part of the API
  though and so we don't want to drop them.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
4 years agoWhen an item is added to an array, then the array is realloc()ed (to size+1),
Tomasz Blaszczak [Wed, 23 Jun 2021 07:17:05 +0000 (09:17 +0200)] 
When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, memory allocated for that item
should be freed, successive items should be left-shifted and the array
realloc()ed again (size-1).

Additional changes:
- If strdup() fails in add_to_array(), then an array should be
  realloc()ed again to original size.
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.blaszczak@consult.red>
4 years agocgroups: verify that hierarchies are non-empty
Christian Brauner [Mon, 28 Jun 2021 07:44:20 +0000 (09:44 +0200)] 
cgroups: verify that hierarchies are non-empty

Fixes: #3881
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxc-download: Switch GPG server
Stéphane Graber [Mon, 28 Jun 2021 03:42:52 +0000 (23:42 -0400)] 
lxc-download: Switch GPG server

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoResize array in remove_from_array() and fix a crash
Tomasz Blaszczak [Fri, 25 Jun 2021 10:04:49 +0000 (12:04 +0200)] 
Resize array in remove_from_array() and fix a crash

When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, allocated memory pointed by
the item (not the item itself) should be freed, successive items should
be left-shifted and the array realloc()ed again (size-1).

Additional changes:
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.blaszczak@consult.red>
4 years agoWhen an item is added to an array, then the array is realloc()ed (to size+1),
Tomasz Blaszczak [Wed, 23 Jun 2021 07:17:05 +0000 (09:17 +0200)] 
When an item is added to an array, then the array is realloc()ed (to size+1),
and the item is copied (strdup()) to the array.
Thus, when an item is removed from an array, memory allocated for that item
should be freed, successive items should be left-shifted and the array
realloc()ed again (size-1).

Additional changes:
- If strdup() fails in add_to_array(), then an array should be
  realloc()ed again to original size.
- Initialize an array in list_all_containers().

Signed-off-by: Tomasz Blaszczak <tomasz.blaszczak@consult.red>
4 years agocgroups: use stable ordering for co-mounted v1 controllers
Christian Brauner [Wed, 16 Jun 2021 08:03:42 +0000 (10:03 +0200)] 
cgroups: use stable ordering for co-mounted v1 controllers

Fixes: #3703
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: replace problematic terminology
Christian Brauner [Mon, 14 Jun 2021 15:26:24 +0000 (17:26 +0200)] 
tree-wide: replace problematic terminology

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: replace problematic terminology
Christian Brauner [Mon, 14 Jun 2021 15:25:39 +0000 (17:25 +0200)] 
tree-wide: replace problematic terminology

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: replace problematic terminology
Christian Brauner [Mon, 14 Jun 2021 15:21:44 +0000 (17:21 +0200)] 
tree-wide: replace problematic terminology

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: remove problematic terminology
Christian Brauner [Mon, 14 Jun 2021 15:15:43 +0000 (17:15 +0200)] 
tree-wide: remove problematic terminology

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoseccomp: replace problematic terminology
Christian Brauner [Mon, 14 Jun 2021 15:14:26 +0000 (17:14 +0200)] 
seccomp: replace problematic terminology

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommon.conf: replace problematic terminology
Christian Brauner [Mon, 14 Jun 2021 15:13:00 +0000 (17:13 +0200)] 
common.conf: replace problematic terminology

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoAdd support for LISTEN_FDS environment variable.
Ruben Jenster [Wed, 2 Jun 2021 14:31:31 +0000 (16:31 +0200)] 
Add support for LISTEN_FDS environment variable.

The LISTEN_FDS environment variable defines the number of
file descriptors that should be inherited by the container,
in addition to stdio.
The LISTEN_FDS environment variable is defined in the OCI spec
and used to support socket activation.

Refs #3845

Signed-off-by: Ruben Jenster <r.jenster@drachenfels.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostring utils: Make sure don't return uninitialized memory.
LiFeng [Sat, 12 Jun 2021 06:52:46 +0000 (14:52 +0800)] 
string utils: Make sure don't return uninitialized memory.

The function lxc_string_split_quoted and lxc_string_split_and_trim use
realloc to reduce the memory. But the result may be NULL, the the
returned memory will be uninitialized

Signed-off-by: LiFeng <lifeng68@huawei.com>
4 years agoconfile: backport lxc.init.groups config key 3866/head
Christian Brauner [Mon, 14 Jun 2021 10:10:46 +0000 (12:10 +0200)] 
confile: backport lxc.init.groups config key

This is needed for lxcri.

Fixes: #3862
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoapi_extensions: introduce idmapped_mounts_v2 api extension
Christian Brauner [Tue, 8 Jun 2021 13:59:13 +0000 (15:59 +0200)] 
api_extensions: introduce idmapped_mounts_v2 api extension

This indicates that LXC supports idmapping the rootfs and
idmapped lxc.mount.entry entries.

Link: https://github.com/lxc/lxd/issues/8870
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotools/lxc_autostart: fix failed count
Christian Brauner [Tue, 8 Jun 2021 12:59:12 +0000 (14:59 +0200)] 
tools/lxc_autostart: fix failed count

Don't include skipped containers in the failed count.

Fixes: #3857
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolsm/apparmor: actually report an error when we fail to wire AppArmor profile
Christian Brauner [Mon, 7 Jun 2021 13:37:38 +0000 (15:37 +0200)] 
lsm/apparmor: actually report an error when we fail to wire AppArmor profile

Link: https://bugs.launchpad.net/ubuntu-kernel-tests/+bug/1931064
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agolxc: add lpthread to lxc.pc
Christian Brauner [Thu, 3 Jun 2021 13:37:11 +0000 (15:37 +0200)] 
lxc: add lpthread to lxc.pc

Fixes: #3853
Suggested-by: Tycho Andersen <tycho@tycho.pizza>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoUpdate lxc-net to support nftables
Pablo Correa Gómez [Thu, 27 May 2021 13:43:31 +0000 (15:43 +0200)] 
Update lxc-net to support nftables

Closes #3093
Closes #3602

Add support for nftables firewall rules if `nft` command line
interface is available in the system

Signed-off-by: Pablo Correa Gómez <ablocorrea@hotmail.com>
4 years agonetwork: please broken compilers
Christian Brauner [Tue, 25 May 2021 12:24:01 +0000 (14:24 +0200)] 
network: please broken compilers

Some users report that compilation fails because of reports that this
variable can be used uninitialized. Initialize it to silence the
compiler.

Fixes: https://github.com/lxc/lxc/issues/3850
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoREADME: Update IRC
Stéphane Graber [Mon, 24 May 2021 04:18:01 +0000 (00:18 -0400)] 
README: Update IRC

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agostart: simplify startup synchronization
Christian Brauner [Fri, 21 May 2021 10:14:47 +0000 (12:14 +0200)] 
start: simplify startup synchronization

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostart: reorder START_SYNC_POST_CONFIGURE
Christian Brauner [Fri, 21 May 2021 09:18:21 +0000 (11:18 +0200)] 
start: reorder START_SYNC_POST_CONFIGURE

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostart: use barrier instead of wake/wait pair
Christian Brauner [Fri, 21 May 2021 09:07:33 +0000 (11:07 +0200)] 
start: use barrier instead of wake/wait pair

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: use explicit signage in bit field
Christian Brauner [Fri, 21 May 2021 08:30:38 +0000 (10:30 +0200)] 
conf: use explicit signage in bit field

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: move file descriptor synchronization with parent into single function
Christian Brauner [Fri, 21 May 2021 08:12:29 +0000 (10:12 +0200)] 
conf: move file descriptor synchronization with parent into single function

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: move file descriptor synchronization with child into single function
Christian Brauner [Fri, 21 May 2021 08:06:27 +0000 (10:06 +0200)] 
conf: move file descriptor synchronization with child into single function

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