]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
2 years agoFix off-by-one error constructing mount options 4219/head
srd424 [Sun, 3 Jul 2022 09:21:30 +0000 (10:21 +0100)] 
Fix off-by-one error constructing mount options

This fixes a really subtle off-by-one error constructing overlay mount options if rootfs options are provided and modern overlayfs (i.e. requiring a workdir) is used. We need to allow for the extra "," required to separate the extra options when computing the length!

Signed-off-by: srd424 <srd424@users.noreply.github.com>
(cherry picked from commit df3301046fc5f31881a2d4736cc5c381342ecc3d)

3 years agocgroups: modify cgroup2 attach logic
Christian Brauner [Wed, 23 Feb 2022 14:40:20 +0000 (15:40 +0100)] 
cgroups: modify cgroup2 attach logic

Recent kernels have seen various permission checking fixes when moving
processes into cgroups. So we're forced to modify how we attach to
containers.

Link: https://discuss.linuxcontainers.org/t/lxd-4-23-unable-to-start-nested-containers
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agottys: ensure container_ttys= env variable is set correctly
Christian Brauner [Tue, 22 Feb 2022 11:17:23 +0000 (12:17 +0100)] 
ttys: ensure container_ttys= env variable is set correctly

Fixes: #4088
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agodoc: Fix reverse allowlist/denylist in Japanese man page
KATOH Yasufumi [Mon, 21 Feb 2022 13:17:36 +0000 (22:17 +0900)] 
doc: Fix reverse allowlist/denylist in Japanese man page

Update for commit 2965130c45124a01f017144512c39fc39fa8717c

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
3 years agocgroups: log fd of newly created cgroup
Christian Brauner [Sun, 20 Feb 2022 14:51:13 +0000 (15:51 +0100)] 
cgroups: log fd of newly created cgroup

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: check that opened file descriptor is a cgroup filesystem
Christian Brauner [Sun, 20 Feb 2022 14:47:28 +0000 (15:47 +0100)] 
cgroups: check that opened file descriptor is a cgroup filesystem

Link: https://discuss.linuxcontainers.org/t/lxd-4-23-unable-to-start-nested-containers/13416
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agodoc: Fix reverse allowlist/denylist
Stéphane Graber [Thu, 3 Feb 2022 02:28:55 +0000 (21:28 -0500)] 
doc: Fix reverse allowlist/denylist

Reported at: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1957934
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agolxc-checkconfig: Fix bashism
Stéphane Graber [Thu, 3 Feb 2022 02:11:09 +0000 (21:11 -0500)] 
lxc-checkconfig: Fix bashism

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agolxc-net: don't start by default inside lxc
Antonio Terceiro [Wed, 2 Feb 2022 18:11:02 +0000 (15:11 -0300)] 
lxc-net: don't start by default inside lxc

When lxc is installed inside an lxc container, trying to bring up
lxc-net with the default parameters will conflict with the networking
setup for lxc on the host. This breaks all networking inside the
container where lxc is installed.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
3 years agoRelease LXC 4.0.12 lxc-4.0.12
Stéphane Graber [Wed, 2 Feb 2022 04:26:09 +0000 (23:26 -0500)] 
Release LXC 4.0.12

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agolxccontainer: allow xdev when creating the container dir
Christian Brauner [Fri, 21 Jan 2022 08:44:01 +0000 (09:44 +0100)] 
lxccontainer: allow xdev when creating the container dir

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agogithub: Clear default ACL on /home
Stéphane Graber [Thu, 20 Jan 2022 16:05:19 +0000 (11:05 -0500)] 
github: Clear default ACL on /home

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agogithub: add systemd-coredump
Christian Brauner [Thu, 20 Jan 2022 11:35:06 +0000 (12:35 +0100)] 
github: add systemd-coredump

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agogithub: more detailed compilation instructions
Christian Brauner [Thu, 20 Jan 2022 11:33:57 +0000 (12:33 +0100)] 
github: more detailed compilation instructions

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agogithub: log system info
Christian Brauner [Thu, 20 Jan 2022 11:23:35 +0000 (12:23 +0100)] 
github: log system info

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agogithub: ensure system liblxc is wiped
Christian Brauner [Thu, 20 Jan 2022 09:34:02 +0000 (10:34 +0100)] 
github: ensure system liblxc is wiped

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: properly wrap lxcapi_create()
Christian Brauner [Thu, 20 Jan 2022 09:14:13 +0000 (10:14 +0100)] 
lxccontainer: properly wrap lxcapi_create()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobuild: simplify thread local storage handling
Christian Brauner [Thu, 20 Jan 2022 08:57:21 +0000 (09:57 +0100)] 
build: simplify thread local storage handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobuild: only enable LTO for regular builds
Christian Brauner [Thu, 20 Jan 2022 08:42:28 +0000 (09:42 +0100)] 
build: only enable LTO for regular builds

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: simplify partial file creation
Christian Brauner [Tue, 18 Jan 2022 17:44:37 +0000 (18:44 +0100)] 
lxccontainer: simplify partial file creation

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: improve create_partial()
Christian Brauner [Tue, 18 Jan 2022 16:48:29 +0000 (17:48 +0100)] 
lxccontainer: improve create_partial()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: improve do_lxcapi_create()
Christian Brauner [Tue, 18 Jan 2022 16:25:07 +0000 (17:25 +0100)] 
lxccontainer: improve do_lxcapi_create()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxccontainer: improve do_lxcapi_save_config()
Christian Brauner [Tue, 18 Jan 2022 15:57:47 +0000 (16:57 +0100)] 
lxccontainer: improve do_lxcapi_save_config()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: log termination status
Christian Brauner [Tue, 18 Jan 2022 15:26:58 +0000 (16:26 +0100)] 
conf: log termination status

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: improve userns_exec_mapped_root()
Christian Brauner [Tue, 18 Jan 2022 15:14:13 +0000 (16:14 +0100)] 
conf: improve userns_exec_mapped_root()

As we do in all other places, first drop groups, then use
setres{g,u}id().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agogithub: stop installing gnupg now that it's unused
Simon Deziel [Tue, 18 Jan 2022 14:53:45 +0000 (09:53 -0500)] 
github: stop installing gnupg now that it's unused

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
3 years agolxc-download: Rely on HTTPS only
Stéphane Graber [Tue, 18 Jan 2022 02:15:53 +0000 (21:15 -0500)] 
lxc-download: Rely on HTTPS only

GPG has been a major source of issues over the years with various
attacks on the key network as well as client side issues making it hard
to retrieve our keys.

Back when we introduced the image server, SSL certificates were still
expensive and annoying to setup, so not something we'd have expected
potential mirrors to setup for us. They were also issued for multiple
years, making a compromise of such a certificate quite problematic.

But things have changed since, we now have completely free, very easily
deployable SSL certificates everywhere with the majority of those being
shortlived and with good reporting of issued certificates.

With that, we can now deprecate the GPG validation, disable the fallback
to non-HTTPS download and rely on our indices being accurate because
they've been downloaded from a server with a valid certificate.

This puts LXC more in line with what LXD has done since the beginning
and should offer a more reliable user experience.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agoUpdate README.md: Fix broken link (403 Forbidden)
Devin Norgarb [Fri, 14 Jan 2022 16:04:16 +0000 (18:04 +0200)] 
Update README.md: Fix broken link (403 Forbidden)

Signed-off-by: Devin Norgarb dnorgarb@gmail.com
3 years agoattach: don't pointlessly call cgroup_init()
Christian Brauner [Thu, 13 Jan 2022 17:48:15 +0000 (18:48 +0100)] 
attach: don't pointlessly call cgroup_init()

We can let attach detect that it is running on a cgroup layout without
writable cgroup hierarchies. In that case attach can finish early and
doesn't need to run the heavy-handed cgroup parsing code.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocommands: log command during file descriptor retrieval
Christian Brauner [Thu, 13 Jan 2022 16:42:17 +0000 (17:42 +0100)] 
commands: log command during file descriptor retrieval

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxc-checkconfig.in: CONFIG_NF_NAT_IPV4 was removed from the kernel 2019-03-03
Tim [Wed, 12 Jan 2022 14:55:25 +0000 (09:55 -0500)] 
lxc-checkconfig.in: CONFIG_NF_NAT_IPV4 was removed from the kernel 2019-03-03

Signed-off-by: Tim L <elatllat@gmail.com>
3 years ago(trivial) Fix error message, failure was connect not bind
Serge Hallyn [Sun, 9 Jan 2022 16:16:02 +0000 (10:16 -0600)] 
(trivial) Fix error message, failure was connect not bind

Signed-off-by: Serge Hallyn <serge@hallyn.com>
3 years agoseccomp: close seccomp notifier fd in cleanup handler
Christian Brauner [Fri, 7 Jan 2022 12:42:33 +0000 (13:42 +0100)] 
seccomp: close seccomp notifier fd in cleanup handler

Reported-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoseccomp: only guard seccomp notify behind HAVE_DECL_SECCOMP_NOTIFY_FD
Christian Brauner [Fri, 10 Dec 2021 16:05:11 +0000 (17:05 +0100)] 
seccomp: only guard seccomp notify behind HAVE_DECL_SECCOMP_NOTIFY_FD

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoapi-extensions: don't advertise seccomp notify support if it's not compiled in
Christian Brauner [Wed, 8 Dec 2021 09:41:59 +0000 (10:41 +0100)] 
api-extensions: don't advertise seccomp notify support if it's not compiled in

Link: https://discuss.linuxcontainers.org/t/runtimeerror-failed-to-read-zi-bytes-from-dev-urandom
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agouse 2 sysfs instances for sys:mixed
Wolfgang Bumiller [Fri, 3 Dec 2021 08:13:11 +0000 (09:13 +0100)] 
use 2 sysfs instances for sys:mixed

In order to facilitate this, the default mount list's
'destination' may now be NULL to mean that the source should
be unmounted instead.

Here's what we need to do:

1) Ensure the first sysfs mount point is writable.
2) Mount a read-only sysfs on /sys
3) Bind devices/virtual/net *writably* into /sys

We use /proc/sys as a staging directory for the first sysfs
mount in read-write mode, then mount /sys r/o. Afterwards we
bind the r/w devices/virtual/net and unmount the staging
/proc/sys mount point.

The staging directory would not be required with the new
mount API, but this way we can support the old API and keep
the general workflow in the `default_mounts`.

Once we drop support for the old mount API, the
default_mounts table could just get a subdirectory field to
mount subdirectories directly.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoRevert "api: ->save_config() doesn't need to create container dir"
Stéphane Graber [Tue, 30 Nov 2021 22:39:34 +0000 (17:39 -0500)] 
Revert "api: ->save_config() doesn't need to create container dir"

This reverts commit 2fde07c3990fe09925699da5d9a1762eb279c497.

We need to investigate this in more detail but this commit is breaking
LXD, causing startup to fail with:

lxc foo 20211130202833.906 INFO     conf - conf.c:run_script_argv:336 - Executing script "/bin/mount -t shiftfs -o passthrough=3 "/lxc-ci/build/tmp.WemmpzWGYz/go/src/github.com/lxc/lxd/test/tmp.Cli/0To/containers/foo/rootfs" "/lxc-ci/build/tmp.WemmpzWGYz/go/src/github.com/lxc/lxd/test/tmp.Cli/0To/containers/foo/rootfs"" for container "foo"
lxc foo 20211130202833.912 ERROR    conf - conf.c:run_buffer:321 - Script exited with status 32
lxc foo 20211130202833.912 ERROR    conf - conf.c:lxc_setup_rootfs_prepare_root:3947 - Failed to run pre-mount hooks
lxc foo 20211130202833.912 ERROR    conf - conf.c:lxc_setup:4317 - Failed to setup rootfs
lxc foo 20211130202833.912 ERROR    start - start.c:do_start:1275 - Failed to setup container "foo"

Not entirely sure why we're seeing things blow up as the directory
definitely exists (and contains a valid rootfs) but this was caused by
today's liblxc update.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agoapi: ->save_config() doesn't need to create container dir
Tycho Andersen [Mon, 29 Nov 2021 13:23:17 +0000 (08:23 -0500)] 
api: ->save_config() doesn't need to create container dir

If we're saving the config file to somewhere that's *not* the container
dir, we don't need to create the container dir. Let's not do this and
thus not require its parent to exist, which can be confusing, especially in
light of the sparse logging through these functions.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
3 years agocgroups: fix compiler warning
Tycho Andersen [Mon, 29 Nov 2021 13:38:30 +0000 (08:38 -0500)] 
cgroups: fix compiler warning

I get:

In file included from cgroups/cgfsng.c:42:
In function 'cpuset1_cpus_initialize',
    inlined from 'cpuset1_initialize' at cgroups/cgfsng.c:658:7,
    inlined from '__cgroup_tree_create.constprop' at cgroups/cgfsng.c:723:26:
./log.h:376:9: error: '%s' directive argument is null [-Werror=format-overflow=]
  376 |         LXC_ERROR(&locinfo, format, ##__VA_ARGS__);                     \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./log.h:457:17: note: in expansion of macro 'ERROR'
  457 |                 ERROR("%s - " format, ptr, ##__VA_ARGS__); \
      |                 ^~~~~
./log.h:491:17: note: in expansion of macro 'SYSERROR'
  491 |                 SYSERROR(format, ##__VA_ARGS__);              \
      |                 ^~~~~~~~
cgroups/cgfsng.c:585:24: note: in expansion of macro 'log_error_errno'
  585 |                 return log_error_errno(false, errno, "Failed to read file \"%s\"", fpath);
      |                        ^~~~~~~~~~~~~~~

it turns out here that fpath is not used, so let's get rid of it and just
render the dfd+pathname directly.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
3 years agoRevert "initutils: use vfork() in lxc_container_init()"
Wolfgang Bumiller [Sat, 13 Nov 2021 17:20:13 +0000 (18:20 +0100)] 
Revert "initutils: use vfork() in lxc_container_init()"

This reverts commit d65e5e492f740bbb50e3005f97420c3ddae3d595.

With vfork the child process modifies the parent's memory,
so the calls to `signal`, `fprintf` and regular `exit` may
be dangerous and might cause conflicting states in the
parent.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agomacro: ensure necessary io_uring flags are defined
Christian Brauner [Tue, 9 Nov 2021 13:01:35 +0000 (14:01 +0100)] 
macro: ensure necessary io_uring flags are defined

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoautotools: Avoid multiple liblxc.so with --enable-pam
Joan Bruguera [Sun, 7 Nov 2021 11:38:15 +0000 (12:38 +0100)] 
autotools: Avoid multiple liblxc.so with --enable-pam

When installing LXC with the default options, a single non-symlink liblxc.so*
(e.g. liblxc.so.1.7.0) file is created:

```
    $ ./autogen.sh && ./configure && make && \
    rm -rf "$HOME/lxci" && make DESTDIR="$HOME/lxci" install && \
    stat -c%N "$HOME/lxci/usr/local/lib/liblxc.so"*
    [...]
    '/home/someone/lxci/usr/local/lib/liblxc.so' -> 'liblxc.so.1'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1' -> 'liblxc.so.1.7.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1.7.0'
```

However, when automake>=1.16.5, and the `--enable-pam` option is used, two
non-symlink liblxc.so* (e.g. liblxc.so.1.0.0 and liblxc.so.1.7.0) are
erroneously created:

```
    $ ./autogen.sh && ./configure --enable-pam && make && \
    rm -rf "$HOME/lxci" && make DESTDIR="$HOME/lxci" install && \
    stat -c%N "$HOME/lxci/usr/local/lib/liblxc.so"*
    [...]
    '/home/someone/lxci/usr/local/lib/liblxc.so' -> 'liblxc.so.1.0.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1' -> 'liblxc.so.1.0.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1.0.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1.7.0'
```

This is due to infighting between libtool's and LXC's versioning:
libtool creates liblxc.so.1.0.0, then LXC's `install-exec-local` hook in
`Makefile.am` moves it to liblxc.so.1.7.0. However, with `--enable-pam`, the
`install-libLTLIBRARIES` target is re-triggered after `install-pamLTLIBRARIES`,
which will create liblxc.so.1.0.0 again.

The bigger problem here is that the install for the pam_cgfs library is done on
the `data` phase of the automake install process instead of the `exec` phase
(https://www.gnu.org/software/automake/manual/html_node/The-Two-Parts-of-Install.html),
which gives `install-libLTLIBRARIES` a chance to run again after the
`install-exec-local` / `install-exec-hook` targets have already run.

To fix this, we add an "exec_" prefix to the pam_cgfs library to make it run
during the `exec` phase (see link above). We also consolidate the various hooks
in the `install-exec-hook` target, which runs after the whole install, avoiding
needing to manually specify the dependencies like in `install-exec-local`.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
3 years agobuild: refuse to compile with unsupported liburing version
Christian Brauner [Thu, 4 Nov 2021 14:45:58 +0000 (15:45 +0100)] 
build: refuse to compile with unsupported liburing version

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: add lxc.proc.* test
Christian Brauner [Thu, 4 Nov 2021 13:05:25 +0000 (14:05 +0100)] 
tests: add lxc.proc.* test

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: add lxc.sysctls.* test
Christian Brauner [Thu, 4 Nov 2021 10:59:08 +0000 (11:59 +0100)] 
tests: add lxc.sysctls.* test

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotest: improve logging helpers
Christian Brauner [Thu, 4 Nov 2021 11:13:02 +0000 (12:13 +0100)] 
test: improve logging helpers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: improve logging setting sysctl and /proc/<pid>/ parameters
Christian Brauner [Thu, 4 Nov 2021 12:46:52 +0000 (13:46 +0100)] 
conf: improve logging setting sysctl and /proc/<pid>/ parameters

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: apply /proc/sys and /proc/<pid>/ parameters
Christian Brauner [Thu, 4 Nov 2021 10:26:00 +0000 (11:26 +0100)] 
conf: apply /proc/sys and /proc/<pid>/ parameters

When porting to the new list type we added an accidental ! when checking
whether the list is empty.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: include config.h
Christian Brauner [Tue, 2 Nov 2021 10:06:33 +0000 (11:06 +0100)] 
tests: include config.h

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobuild: move _FILE_OFFSET_BITS to common option
Christian Brauner [Tue, 2 Nov 2021 09:57:24 +0000 (10:57 +0100)] 
build: move _FILE_OFFSET_BITS to common option

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agostart: log signal name and number
Christian Brauner [Tue, 2 Nov 2021 09:48:52 +0000 (10:48 +0100)] 
start: log signal name and number

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoprocess_utils: add signal_name() helper
Christian Brauner [Tue, 2 Nov 2021 09:42:09 +0000 (10:42 +0100)] 
process_utils: add signal_name() helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobuild: improve liburing support detection
Christian Brauner [Sat, 30 Oct 2021 15:45:50 +0000 (17:45 +0200)] 
build: improve liburing support detection

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agomainloop: make ifdefs easier to follow
Christian Brauner [Sat, 30 Oct 2021 15:38:37 +0000 (17:38 +0200)] 
mainloop: make ifdefs easier to follow

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoReplace last occurence of 'which' with 'command -v'
Simon Deziel [Thu, 28 Oct 2021 17:09:48 +0000 (13:09 -0400)] 
Replace last occurence of 'which' with 'command -v'

The later is builtin and POSIX compliant.

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
3 years agoReplace deprecated backticks with $() construct
Diederik de Haas [Thu, 28 Oct 2021 17:30:05 +0000 (19:30 +0200)] 
Replace deprecated backticks with $() construct

See https://github.com/koalaman/shellcheck/wiki/SC2006 for details.
Not only uses this the recommended construct, it also makes the code
more uniform as in many other places the $() construct was already used.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
3 years agoReplace 'which' with 'command -v' in tests too
Diederik de Haas [Thu, 28 Oct 2021 16:25:37 +0000 (18:25 +0200)] 
Replace 'which' with 'command -v' in tests too

Forgot to modify and include the tests in previous PR, so do that now.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
3 years agostart: check event loop type before closing fd
Christian Brauner [Thu, 28 Oct 2021 15:39:42 +0000 (17:39 +0200)] 
start: check event loop type before closing fd

Since this is a union we might otherwise stomp on io_uring mmap()ed
memory.

Fixes: #4016
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agomainloop: make sure that descr->ring is allocated
Christian Brauner [Thu, 28 Oct 2021 15:39:11 +0000 (17:39 +0200)] 
mainloop: make sure that descr->ring is allocated

This is future proofing more than anything else.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoReplace 'which' with 'command -v'
Diederik de Haas [Thu, 28 Oct 2021 15:27:08 +0000 (17:27 +0200)] 
Replace 'which' with 'command -v'

The 'which' command is deprecated on Debian Sid as it is not POSIX
compliant and it's behavior is therefor not consistent, so replace it
with 'command -v' which is POSIX compliant.
See https://stackoverflow.com/a/677212 for details.

Also replaced a use of backticks (`) as that is deprecated as well.
See https://github.com/koalaman/shellcheck/wiki/SC2006 for details.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
3 years agobuild: add io-uring-event-loop option
Christian Brauner [Thu, 28 Oct 2021 15:07:27 +0000 (17:07 +0200)] 
build: add io-uring-event-loop option

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agobuild: add static libcap to output
Christian Brauner [Thu, 28 Oct 2021 15:07:14 +0000 (17:07 +0200)] 
build: add static libcap to output

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconfile: don't use path_simplify() on lxc.{execute,init}.cmd
Christian Brauner [Thu, 28 Oct 2021 14:53:14 +0000 (16:53 +0200)] 
confile: don't use path_simplify() on lxc.{execute,init}.cmd

Fixes: #4015
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: add cgroup2, cgroup2:ro, cgroup2:force, cgroup2:ro:force options
Christian Brauner [Thu, 21 Oct 2021 14:17:59 +0000 (16:17 +0200)] 
conf: add cgroup2, cgroup2:ro, cgroup2:force, cgroup2:ro:force options

We keep running into situations where we want to pre-mount a pure
cgroup2 layout regardless of the layout of the host.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoAUTHORS: Update to point to git history
Stéphane Graber [Mon, 25 Oct 2021 12:53:58 +0000 (08:53 -0400)] 
AUTHORS: Update to point to git history

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agoconf: handle kernels without or not using SMT
Christian Brauner [Sat, 23 Oct 2021 17:15:24 +0000 (19:15 +0200)] 
conf: handle kernels without or not using SMT

On kernel not enabling or not using SMT core scheduling will return with
ENODEV. Handle such kernels.

Link: https://github.com/lxc/lxd/issues/9419
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agodoc: fix typo in English lxc.container.conf(5)
KATOH Yasufumi [Sat, 23 Oct 2021 06:26:26 +0000 (15:26 +0900)] 
doc: fix typo in English lxc.container.conf(5)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
3 years agodoc: Add lxc.sched.core to Japanese lxc.container.conf(5)
KATOH Yasufumi [Sat, 23 Oct 2021 06:18:00 +0000 (15:18 +0900)] 
doc: Add lxc.sched.core to Japanese lxc.container.conf(5)

Update for commit 09996a4

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
3 years agodoc: add loglevels to ja and ko common options
KATOH Yasufumi [Sat, 23 Oct 2021 05:44:22 +0000 (14:44 +0900)] 
doc: add loglevels to ja and ko common options

Update for commit 44b87e8

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
3 years agoconf: make it more obvious how auto-mount flags are defined
Christian Brauner [Thu, 21 Oct 2021 13:44:58 +0000 (15:44 +0200)] 
conf: make it more obvious how auto-mount flags are defined

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocriu: support restoring containers with pre-created veth devices
Christian Brauner [Wed, 20 Oct 2021 12:48:41 +0000 (14:48 +0200)] 
criu: support restoring containers with pre-created veth devices

We did th CRIU and kernel work but for some reason we never did push the
LXC work.

Link: https://github.com/checkpoint-restore/criu/commit/cdb0d427020f0531f5a35146513c3a36b6eece11
      commit cdb0d427020f ("net: allow restoring of precreated veth devices")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoRelease LXC 4.0.11 lxc-4.0.11
Stéphane Graber [Tue, 19 Oct 2021 16:01:41 +0000 (12:01 -0400)] 
Release LXC 4.0.11

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
3 years agoconf: verify that rootfs is stable after setting up mounts
Christian Brauner [Tue, 19 Oct 2021 14:57:05 +0000 (16:57 +0200)] 
conf: verify that rootfs is stable after setting up mounts

Apparently some users changed their rootfs via their lxc.mount.entry
entries. Let's not allow that as that can cause confusion during
container setup. So lets verify that the rootfs is stable after setup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoREADME.md: mention RISC-V architecture
Heinrich Schuchardt [Tue, 19 Oct 2021 11:16:33 +0000 (13:16 +0200)] 
README.md: mention RISC-V architecture

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
3 years agoAdd riscv64 to --arch parameter values
Heinrich Schuchardt [Tue, 19 Oct 2021 07:56:21 +0000 (09:56 +0200)] 
Add riscv64 to --arch parameter values

lxc-attach uses an --arch parameter. 'riscv64' should be a usable value.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
3 years agoconf: don't fail umount2()
Christian Brauner [Mon, 18 Oct 2021 10:07:37 +0000 (12:07 +0200)] 
conf: don't fail umount2()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: fix coding style
Christian Brauner [Mon, 18 Oct 2021 09:46:16 +0000 (11:46 +0200)] 
conf: fix coding style

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocaps: ensure \0-termination
Christian Brauner [Fri, 15 Oct 2021 09:29:27 +0000 (11:29 +0200)] 
caps: ensure \0-termination

Fixes: Coverity 1492865
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: improve error logging
Christian Brauner [Fri, 15 Oct 2021 08:06:48 +0000 (10:06 +0200)] 
attach: improve error logging

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoaf_unix: replace log_error_errno()
Christian Brauner [Fri, 15 Oct 2021 07:59:28 +0000 (09:59 +0200)] 
af_unix: replace log_error_errno()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocriu: fix error message
Tycho Andersen [Thu, 14 Oct 2021 16:40:08 +0000 (10:40 -0600)] 
criu: fix error message

as of 59d8a539d106 ("criu: massage exec_criu()") I see:

In file included from criu.c:22:
criu.c: In function 'exec_criu':
log.h:376:2: error: '%s' directive argument is null [-Werror=format-overflow=]
  376 |  LXC_ERROR(&locinfo, format, ##__VA_ARGS__);   \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log.h:457:3: note: in expansion of macro 'ERROR'
  457 |   ERROR("%s - " format, ptr, ##__VA_ARGS__); \
      |   ^~~~~
log.h:491:3: note: in expansion of macro 'SYSERROR'
  491 |   SYSERROR(format, ##__VA_ARGS__);              \
      |   ^~~~~~~~
criu.c:325:11: note: in expansion of macro 'log_error_errno'
  325 |    return log_error_errno(-ENOMEM, ENOMEM, "Failed to remove extraneous slashes from \"%s\"", tmp);
      |           ^~~~~~~~~~~~~~~

it looks like we should be logging the string that failed, vs. tmp here.

(my log was taken from stable-4.0, but the same issue exists on master it
seems.)

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
3 years agotests: remove trailing endifs
Christian Brauner [Thu, 14 Oct 2021 15:35:48 +0000 (17:35 +0200)] 
tests: remove trailing endifs

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxc-monitord: fix integer comparisions
Christian Brauner [Thu, 14 Oct 2021 15:34:25 +0000 (17:34 +0200)] 
lxc-monitord: fix integer comparisions

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotest: fix nested capability tests
Christian Brauner [Thu, 14 Oct 2021 11:59:34 +0000 (13:59 +0200)] 
test: fix nested capability tests

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: improve error logging for drop_capabilities()
Christian Brauner [Thu, 14 Oct 2021 09:52:06 +0000 (11:52 +0200)] 
attach: improve error logging for drop_capabilities()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: expand capability tests
Christian Brauner [Thu, 14 Oct 2021 09:17:15 +0000 (11:17 +0200)] 
tests: expand capability tests

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotree-wide: use __u32 for capabilities
Christian Brauner [Wed, 13 Oct 2021 16:51:48 +0000 (18:51 +0200)] 
tree-wide: use __u32 for capabilities

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agocgroups: use __u32 for cpumasks
Christian Brauner [Wed, 13 Oct 2021 16:30:00 +0000 (18:30 +0200)] 
cgroups: use __u32 for cpumasks

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: improve capability handling
Christian Brauner [Wed, 13 Oct 2021 11:38:14 +0000 (13:38 +0200)] 
conf: improve capability handling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotests: add test for lxc.cap.keep
Christian Brauner [Tue, 12 Oct 2021 14:48:02 +0000 (16:48 +0200)] 
tests: add test for lxc.cap.keep

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoconf: fix lxc.cap.keep behavior
Christian Brauner [Tue, 12 Oct 2021 14:33:14 +0000 (16:33 +0200)] 
conf: fix lxc.cap.keep behavior

Fixes: ##3993
Fixes: 20ab75789eb9 ("conf: simplify and port caps to new list type")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoterminal: log at warning message
Christian Brauner [Mon, 11 Oct 2021 13:21:45 +0000 (15:21 +0200)] 
terminal: log at warning message

The lxc_devpts_terminal() helper is called in contexts where it can fail
due to various reasons but where we safely fallback to allocating
terminal devices on the host. Logging error messages irritates users so
just log warning messages.

Link: https://discuss.linuxcontainers.org/t/lxc-attach-error-failed-to-open-terminal-multiplexer-device
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolog: improve %m handling on musl
Christian Brauner [Mon, 4 Oct 2021 09:23:55 +0000 (11:23 +0200)] 
log: improve %m handling on musl

Fixes: #3961
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agostart: make failure to apply core scheduling fatal
Christian Brauner [Fri, 1 Oct 2021 08:27:04 +0000 (10:27 +0200)] 
start: make failure to apply core scheduling fatal

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agostart: use core scheduling error helper
Christian Brauner [Fri, 1 Oct 2021 08:14:08 +0000 (10:14 +0200)] 
start: use core scheduling error helper

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agostart: don't fail when core scheduling isn't supported
Christian Brauner [Fri, 1 Oct 2021 08:12:43 +0000 (10:12 +0200)] 
start: don't fail when core scheduling isn't supported

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agosyscall_wrappers: fix core scheduling creation helper naming
Christian Brauner [Fri, 1 Oct 2021 08:12:17 +0000 (10:12 +0200)] 
syscall_wrappers: fix core scheduling creation helper naming

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agotree-wide: cast to core scheduling cookie to llu
Christian Brauner [Thu, 30 Sep 2021 20:48:04 +0000 (22:48 +0200)] 
tree-wide: cast to core scheduling cookie to llu

Link: https://launchpadlibrarian.net/561086365/buildlog_ubuntu-focal-ppc64el.lxc_1%3A4.0.10+master~20210930-1812-0ubuntu1~focal_BUILDING.txt.gz
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agoattach: handle core scheduling
Christian Brauner [Wed, 29 Sep 2021 12:35:41 +0000 (14:35 +0200)] 
attach: handle core scheduling

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
3 years agolxc: add lxc.sched.core
Christian Brauner [Wed, 29 Sep 2021 11:16:26 +0000 (13:16 +0200)] 
lxc: add lxc.sched.core

Core scheduling defines if the container payload is marked as being
schedulable on the same core. Doing so will cause the kernel scheduler
to ensure that tasks that are not in the same group never run
simultaneously on a core. This can serve as an extra security measure to
prevent the container payload from using cross hyper thread attacks.

The only allowed values are 0 and 1. Set this to 1 to create a core
scheduling domain for the container or 0 to not create one. If not set
explicitly no core scheduling domain will be created for the container.

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