]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
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>
4 years agocgroups: rework check whether legacy hierarchy is writable
Christian Brauner [Fri, 21 May 2021 15:24:38 +0000 (17:24 +0200)] 
cgroups: rework check whether legacy hierarchy is writable

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: fix mount option parsing
Christian Brauner [Wed, 19 May 2021 15:38:20 +0000 (17:38 +0200)] 
conf: fix mount option parsing

Fixes: Coverity 1484906
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfile: free mount data
Christian Brauner [Tue, 18 May 2021 18:23:17 +0000 (20:23 +0200)] 
confile: free mount data

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: add sequence when setting up idmapped mounts
Christian Brauner [Wed, 19 May 2021 09:12:04 +0000 (11:12 +0200)] 
conf: add sequence when setting up idmapped mounts

Make sure we catch any weird behavior.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: support idmapped lxc.mount.entry entries
Christian Brauner [Mon, 17 May 2021 09:41:38 +0000 (11:41 +0200)] 
conf: support idmapped lxc.mount.entry entries

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoSkip rootfs pinning for read-only file system.
Wei Mingzhi [Tue, 18 May 2021 12:37:52 +0000 (20:37 +0800)] 
Skip rootfs pinning for read-only file system.

Signed-off-by: Wei Mingzhi <weimingzhi@baidu.com>
4 years agoconf: rename struct mount_opt flag member s/flag/legacy_flag/
Christian Brauner [Mon, 17 May 2021 10:42:50 +0000 (12:42 +0200)] 
conf: rename struct mount_opt flag member s/flag/legacy_flag/

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: s/parse_mntopts/parse_mntopts_legacy/
Christian Brauner [Mon, 17 May 2021 10:35:37 +0000 (12:35 +0200)] 
tree-wide: s/parse_mntopts/parse_mntopts_legacy/

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostart: move idmapped mount setup later
Christian Brauner [Fri, 14 May 2021 17:00:14 +0000 (19:00 +0200)] 
start: move idmapped mount setup later

At the prior location we we're placed between sending and receiving
networking information over the data socket causing the startup to fail.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: tweak rootfs handling
Christian Brauner [Wed, 12 May 2021 07:34:26 +0000 (09:34 +0200)] 
conf: tweak rootfs handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: don't unmount procfs and sysfs
Christian Brauner [Wed, 12 May 2021 08:19:25 +0000 (10:19 +0200)] 
conf: don't unmount procfs and sysfs

Fixes: #3838
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: allow xdev when setting up /dev
Christian Brauner [Wed, 12 May 2021 07:18:53 +0000 (09:18 +0200)] 
conf: allow xdev when setting up /dev

Fixes: #3838
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocgroups: clean up cgroup_ops on initialization error
Christian Brauner [Tue, 11 May 2021 07:05:03 +0000 (09:05 +0200)] 
cgroups: clean up cgroup_ops on initialization error

Fixes: #3836
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agooss-fuzz: add basic cgroup_init()/cgroup_exit() fuzzing
Christian Brauner [Tue, 4 May 2021 16:40:15 +0000 (18:40 +0200)] 
oss-fuzz: add basic cgroup_init()/cgroup_exit() fuzzing

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoMerge pull request #3835 from brauner/2021-05-10.fixes.apparmor.stable-4.0
Stéphane Graber [Mon, 10 May 2021 16:12:33 +0000 (12:12 -0400)] 
Merge pull request #3835 from brauner/2021-05-10.fixes.apparmor.stable-4.0

confile: convert AppArmor and SELinux confile parsing from errors to …

4 years agoconfile: convert AppArmor and SELinux confile parsing from errors to warnings 3835/head
Christian Brauner [Mon, 10 May 2021 15:39:07 +0000 (17:39 +0200)] 
confile: convert AppArmor and SELinux confile parsing from errors to warnings

Fixes: https://github.com/lxc/lxc/issues/3765#issuecomment-836792820
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: fix lxc-test-arch-parse for make dist
Christian Brauner [Mon, 10 May 2021 15:05:04 +0000 (17:05 +0200)] 
tests: fix lxc-test-arch-parse for make dist

Fixes: https://jenkins.linuxcontainers.org/job/lxc-build-tarballs/2762/console
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotests: add tests for supported architectures
Christian Brauner [Sun, 9 May 2021 14:11:12 +0000 (16:11 +0200)] 
tests: add tests for supported architectures

Ensure that we detect all supported architectures and don't regress
recognizing them.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfile: re-add aarch64 architecture
Christian Brauner [Sun, 9 May 2021 13:44:59 +0000 (15:44 +0200)] 
confile: re-add aarch64 architecture

Apparenty we dropped this when we cleaned up architecture handling.

Fixes: #3832
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoReflow ZFS check to follow the style of the overlayfs return.
Jeff Cook [Sun, 9 May 2021 11:29:05 +0000 (05:29 -0600)] 
Reflow ZFS check to follow the style of the overlayfs return.

Per https://github.com/lxc/lxc/pull/3831#discussion_r628865713

Signed-off-by: Jeff Cook <jeff@jeffcook.io>
4 years agoSkip rootfs pinning for ZFS roots.
Jeff Cook [Sun, 9 May 2021 02:46:42 +0000 (20:46 -0600)] 
Skip rootfs pinning for ZFS roots.

Signed-off-by: Jeff Cook <jeff@jeffcook.io>
4 years agodoc: document new idmap= option for lxc.rootfs.options
Christian Brauner [Fri, 7 May 2021 15:21:18 +0000 (17:21 +0200)] 
doc: document new idmap= option for lxc.rootfs.options

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: handle kernels with CAP_SETFCAP
Christian Brauner [Thu, 6 May 2021 16:16:45 +0000 (18:16 +0200)] 
conf: handle kernels with CAP_SETFCAP

LXC is being very clever and sometimes maps the caller's uid into the
child userns. This means that the caller can technically write fscaps
that are valid in the ancestor userns (which can be a security issue in
some scenarios) so newer kernels require CAP_SETFCAP to do this. Until
newuidmap/newgidmap are updated to account for this simply write the
mapping directly in this case.

Cc: stable-4.0
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoRelease LXC 4.0.9 lxc-4.0.9
Stéphane Graber [Tue, 4 May 2021 16:56:15 +0000 (12:56 -0400)] 
Release LXC 4.0.9

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoattach: introduce explicit personality macro
Christian Brauner [Tue, 4 May 2021 14:16:36 +0000 (16:16 +0200)] 
attach: introduce explicit personality macro

Introduce LXC_ATTACH_DETECT_PERSONALITY to make it explicit what is
happening instead of using -1.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: add personality_t
Christian Brauner [Tue, 4 May 2021 14:09:48 +0000 (16:09 +0200)] 
conf: add personality_t

Catch errors in personality handling better.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoattach_options: unbreak header
Christian Brauner [Tue, 4 May 2021 13:43:38 +0000 (15:43 +0200)] 
attach_options: unbreak header

In a moment of idioticity I switch -1 with 0xffffffff in the header
definition but we use -1 to autodetect.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: rework lxc_config_parse_arch()
Christian Brauner [Tue, 4 May 2021 11:38:52 +0000 (13:38 +0200)] 
conf: rework lxc_config_parse_arch()

Fix architecture parsing. So far we couldn't really differ between "want
default architecture" and "failed to parse requested architecture"
because the -1 return value means both. Fix this by using the return
value only to indicate success or failure and return the parsed
personality in a return argument.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: tweak setup_personality()
Christian Brauner [Tue, 4 May 2021 11:30:20 +0000 (13:30 +0200)] 
conf: tweak setup_personality()

Use the dedicated LXC_ARCH_UNCHANGED macro everywhere instead of relying
on -1 being correct.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agotree-wide: make personality codepaths unconditional
Christian Brauner [Tue, 4 May 2021 11:27:20 +0000 (13:27 +0200)] 
tree-wide: make personality codepaths unconditional

Now that we have the infra to make personality handling unconitional
remove the ifndefs everywhere.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agosyscalls: wrap personality syscall if undefined
Christian Brauner [Tue, 4 May 2021 11:21:28 +0000 (13:21 +0200)] 
syscalls: wrap personality syscall if undefined

There's no need to making personality handling conditional as it has
been around for such a long time that only weird systems wouldn't have
support for it. And especially if the user requested a specific
personality to be set but the system doesn't support the personality
syscall we should loudly fail instead of moving on.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agocommands: log at debug not info level when receiving file descriptors
Christian Brauner [Tue, 4 May 2021 06:59:24 +0000 (08:59 +0200)] 
commands: log at debug not info level when receiving file descriptors

Don't spam the logs because we do receive a lot of file descriptors.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfile: make per_name struct static
Christian Brauner [Tue, 4 May 2021 06:57:52 +0000 (08:57 +0200)] 
confile: make per_name struct static

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostring_utils: get around GCC-11 false positives
Evgeny Vereshchagin [Mon, 3 May 2021 20:44:05 +0000 (20:44 +0000)] 
string_utils: get around GCC-11 false positives

by getting rid of stpncpy

Tested with gcc (GCC) 11.1.1 20210428 (Red Hat 11.1.1-1)

Closes https://github.com/lxc/lxc/issues/3752

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agogithub: also pass the j option to make
Evgeny Vereshchagin [Mon, 3 May 2021 22:35:19 +0000 (22:35 +0000)] 
github: also pass the j option to make

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agogithub: remove the dh-* packages
Evgeny Vereshchagin [Mon, 3 May 2021 22:31:55 +0000 (22:31 +0000)] 
github: remove the dh-* packages

We don't build any packages there so it seems we don't need
those packages any more. Apart from that, it should make the
script work on Ubuntu Hirsute where dh-systemd was merged into
debhelper and is no longer available.

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agogithub: Run apt-get update in sanitizer test
Stéphane Graber [Mon, 3 May 2021 12:02:14 +0000 (08:02 -0400)] 
github: Run apt-get update in sanitizer test

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoconf: fix console chmod error log messages
Aaron Thompson [Sat, 1 May 2021 01:20:14 +0000 (01:20 +0000)] 
conf: fix console chmod error log messages

Signed-off-by: Aaron Thompson <dev@aaront.org>
4 years agooss-fuzz: always turn off logging on OSS-Fuzz
Evgeny Vereshchagin [Fri, 30 Apr 2021 11:08:34 +0000 (11:08 +0000)] 
oss-fuzz: always turn off logging on OSS-Fuzz

Apparently /proc/self/cmd can't be used (reliably) on OSS-Fuzz to figure out
whether the code is run inside the fuzz targets, which causes the
fuzz targets to fill the filesystem with log files.

Related: https://github.com/google/oss-fuzz/issues/5509
Should address https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33835

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agoRelease LXC 4.0.8 lxc-4.0.8
Stéphane Graber [Fri, 30 Apr 2021 18:11:01 +0000 (14:11 -0400)] 
Release LXC 4.0.8

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agocgroups: fix fallback attach codepath
Christian Brauner [Fri, 30 Apr 2021 13:47:35 +0000 (15:47 +0200)] 
cgroups: fix fallback attach codepath

When we attach to an old server the server can return ENOSYS instead of
ENOCGROUP2 which causes LXC to abort the attach unnecessary. Fix this!

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage: fix dup_cloexec() call
Christian Brauner [Fri, 30 Apr 2021 08:35:06 +0000 (10:35 +0200)] 
storage: fix dup_cloexec() call

Fixes: Coverity 1477399
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoRelease LXC 4.0.7 lxc-4.0.7
Stéphane Graber [Thu, 29 Apr 2021 20:55:34 +0000 (16:55 -0400)] 
Release LXC 4.0.7

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
4 years agoapi-extensions: add entry for idmapped_mounts
Christian Brauner [Wed, 28 Apr 2021 13:38:48 +0000 (15:38 +0200)] 
api-extensions: add entry for idmapped_mounts

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: cleanup mount code
Christian Brauner [Wed, 28 Apr 2021 09:33:37 +0000 (11:33 +0200)] 
storage/dir: cleanup mount code

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: remove error handling down
Christian Brauner [Wed, 28 Apr 2021 09:27:58 +0000 (11:27 +0200)] 
storage/dir: remove error handling down

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: source can't be empty
Christian Brauner [Wed, 28 Apr 2021 09:26:59 +0000 (11:26 +0200)] 
storage/dir: source can't be empty

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: use "source" and "target" as terms
Christian Brauner [Wed, 28 Apr 2021 09:26:11 +0000 (11:26 +0200)] 
storage/dir: use "source" and "target" as terms

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: retrieve proper source path later
Christian Brauner [Wed, 28 Apr 2021 09:24:15 +0000 (11:24 +0200)] 
storage/dir: retrieve proper source path later

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: use clear error messages
Christian Brauner [Wed, 28 Apr 2021 09:23:03 +0000 (11:23 +0200)] 
storage/dir: use clear error messages

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agostorage/dir: bdev->dest can't be empty
Christian Brauner [Wed, 28 Apr 2021 09:21:03 +0000 (11:21 +0200)] 
storage/dir: bdev->dest can't be empty

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agodir: use mnt_opts->data instead of mntdata
Christian Brauner [Wed, 28 Apr 2021 09:19:47 +0000 (11:19 +0200)] 
dir: use mnt_opts->data instead of mntdata

Fixes: https://launchpadlibrarian.net/535845165/buildlog_ubuntu-focal-s390x.lxc_1%3A4.0.6+master~20210427-2321-0ubuntu1~focal_BUILDING.txt.gz
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agobuild-system: turn off lto=thin when building the fuzzers
Evgeny Vereshchagin [Tue, 27 Apr 2021 00:03:39 +0000 (00:03 +0000)] 
build-system: turn off lto=thin when building the fuzzers

With lto=thin the fuzzers fail as soon as they start with
```
ERROR: The size of coverage PC tables does not match the
number of instrumented PCs. This might be a compiler bug,
please contact the libFuzzer developers.
Also check https://bugs.llvm.org/show_bug.cgi?id=34636
for possible workarounds (tl;dr: don't use the old GNU ld)
```

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agotests: run the fuzzers along with the other tests
Evgeny Vereshchagin [Mon, 26 Apr 2021 21:41:54 +0000 (21:41 +0000)] 
tests: run the fuzzers along with the other tests

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agolog: create log files in "fuzzing" mode if it's called outside fuzz targets
Evgeny Vereshchagin [Wed, 14 Apr 2021 18:37:08 +0000 (18:37 +0000)] 
log: create log files in "fuzzing" mode if it's called outside fuzz targets

to make it possible to run the fuzzers along with the other tests

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agoci: switch to --enable-fuzzers
Evgeny Vereshchagin [Wed, 14 Apr 2021 09:22:51 +0000 (09:22 +0000)] 
ci: switch to --enable-fuzzers

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agobuild-system: add --enable-fuzzers
Evgeny Vereshchagin [Wed, 14 Apr 2021 09:20:31 +0000 (09:20 +0000)] 
build-system: add --enable-fuzzers

Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
4 years agoconf: improve idmapped mounts support
Christian Brauner [Sun, 25 Apr 2021 10:23:56 +0000 (12:23 +0200)] 
conf: improve idmapped mounts support

Setting up a detached idmapped mount is a privileged operation, mounting
it doesn't have to be.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: s/lxc_rootfs_prepare/lxc_rootfs_init/g
Christian Brauner [Sun, 25 Apr 2021 09:02:15 +0000 (11:02 +0200)] 
conf: s/lxc_rootfs_prepare/lxc_rootfs_init/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: move all mount options into struct lxc_mount_options
Christian Brauner [Sun, 25 Apr 2021 08:24:17 +0000 (10:24 +0200)] 
conf: move all mount options into struct lxc_mount_options

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconf: stash lxc_storage into lxc_rootfs and bind to its lifetime
Christian Brauner [Sun, 25 Apr 2021 07:59:42 +0000 (09:59 +0200)] 
conf: stash lxc_storage into lxc_rootfs and bind to its lifetime

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agoconfigure: fix function detection
Christian Brauner [Sat, 24 Apr 2021 09:19:53 +0000 (11:19 +0200)] 
configure: fix function detection

Fixes: #3809
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
4 years agodir: fix rootfs mounting
Christian Brauner [Fri, 23 Apr 2021 09:29:47 +0000 (11:29 +0200)] 
dir: fix rootfs mounting

We need to be able to lookup symlinks and allow xdev.

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