]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
5 years agocommands_utils: auto free lxc_add_state_client
Christian Brauner [Tue, 19 Feb 2019 22:21:50 +0000 (23:21 +0100)]
commands_utils: auto free lxc_add_state_client

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands_utils: auto close lxc_cmd_sock_get_state
Christian Brauner [Tue, 19 Feb 2019 22:21:08 +0000 (23:21 +0100)]
commands_utils: auto close lxc_cmd_sock_get_state

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2866 from brauner/2019-02-19/cve-2019-5736-test
Christian Brauner [Tue, 19 Feb 2019 20:58:04 +0000 (21:58 +0100)]
Merge pull request #2866 from brauner/2019-02-19/cve-2019-5736-test

cve-2019-5736: add test

5 years agocve-2019-5736: add test
Christian Brauner [Tue, 19 Feb 2019 17:19:18 +0000 (18:19 +0100)]
cve-2019-5736: add test

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2865 from brauner/2019-02-18/rexec_improve_fallbacks
Stéphane Graber [Mon, 18 Feb 2019 22:24:08 +0000 (17:24 -0500)]
Merge pull request #2865 from brauner/2019-02-18/rexec_improve_fallbacks

rexec: try sendfile() fallback to fd_to_fd()

5 years agorexec: try sendfile() fallback to fd_to_fd()
Christian Brauner [Mon, 18 Feb 2019 22:01:43 +0000 (23:01 +0100)]
rexec: try sendfile() fallback to fd_to_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2864 from brauner/2019-02-18/rename_pointer_macros
Stéphane Graber [Mon, 18 Feb 2019 21:36:14 +0000 (16:36 -0500)]
Merge pull request #2864 from brauner/2019-02-18/rename_pointer_macros

tree-wide: s/steal_{fd,ptr}/move_{fd,ptr}/g

5 years agotree-wide: s/steal_fd/move_fd/g
Christian Brauner [Mon, 18 Feb 2019 21:13:42 +0000 (22:13 +0100)]
tree-wide: s/steal_fd/move_fd/g

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agotree-wide: s/steal_ptr/move_ptr/g
Christian Brauner [Mon, 18 Feb 2019 21:12:29 +0000 (22:12 +0100)]
tree-wide: s/steal_ptr/move_ptr/g

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2863 from brauner/2019-02-17/save_rexec
Stéphane Graber [Mon, 18 Feb 2019 20:35:01 +0000 (15:35 -0500)]
Merge pull request #2863 from brauner/2019-02-17/save_rexec

rexec: handle legacy kernels

5 years ago[V2] rexec: handle legacy kernels
Christian Brauner [Mon, 18 Feb 2019 12:32:26 +0000 (13:32 +0100)]
[V2] rexec: handle legacy kernels

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoRevert "rexec: handle legacy kernels"
Stéphane Graber [Mon, 18 Feb 2019 17:15:30 +0000 (12:15 -0500)]
Revert "rexec: handle legacy kernels"

Broke Android

This reverts commit 8f350e637c0e8001398602a6b2f536de3905787d.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
5 years agoMerge pull request #2862 from brauner/2019-02-17/save_rexec
Stéphane Graber [Mon, 18 Feb 2019 16:56:44 +0000 (11:56 -0500)]
Merge pull request #2862 from brauner/2019-02-17/save_rexec

cleanup macros and rexec fixes

5 years agorexec: use __do_close_prot_errno
Christian Brauner [Sun, 17 Feb 2019 14:12:19 +0000 (15:12 +0100)]
rexec: use __do_close_prot_errno

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agorexec: handle legacy kernels
Christian Brauner [Mon, 18 Feb 2019 12:32:26 +0000 (13:32 +0100)]
rexec: handle legacy kernels

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: cleanup macros lxc_cmd_init()
Christian Brauner [Sun, 17 Feb 2019 13:46:25 +0000 (14:46 +0100)]
commands: cleanup macros lxc_cmd_init()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: cleanup macros lxc_cmd_init
Christian Brauner [Sun, 17 Feb 2019 13:44:20 +0000 (14:44 +0100)]
commands: cleanup macros lxc_cmd_init

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: cleanup macros lxc_cmd_accept()
Christian Brauner [Sun, 17 Feb 2019 13:42:51 +0000 (14:42 +0100)]
commands: cleanup macros lxc_cmd_accept()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: cleanup macros lxc_cmd_add_state_client
Christian Brauner [Sun, 17 Feb 2019 13:39:55 +0000 (14:39 +0100)]
commands: cleanup macros lxc_cmd_add_state_client

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: cleanup macros lxc_cmd()
Christian Brauner [Sun, 17 Feb 2019 13:36:52 +0000 (14:36 +0100)]
commands: cleanup macros lxc_cmd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: use __do_close_prot_errno
Christian Brauner [Sun, 17 Feb 2019 13:32:14 +0000 (14:32 +0100)]
commands: use __do_close_prot_errno

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agomemory_utils: introduce __do_close_prot_errno
Christian Brauner [Sun, 17 Feb 2019 13:31:52 +0000 (14:31 +0100)]
memory_utils: introduce __do_close_prot_errno

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agomacro: introduce steal_fd()
Christian Brauner [Sun, 17 Feb 2019 13:31:40 +0000 (14:31 +0100)]
macro: introduce steal_fd()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: cleanup macros in lxc_cmd_console()
Christian Brauner [Sun, 17 Feb 2019 13:24:30 +0000 (14:24 +0100)]
commands: cleanup macros in lxc_cmd_console()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: move declaration into tighter scope
Christian Brauner [Sun, 17 Feb 2019 13:21:09 +0000 (14:21 +0100)]
commands: move declaration into tighter scope

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agolxc-usernsexec: use cleanup macros
Christian Brauner [Sat, 9 Feb 2019 11:05:46 +0000 (12:05 +0100)]
lxc-usernsexec: use cleanup macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agolxc-user-nic: use cleanup macros
Christian Brauner [Sat, 9 Feb 2019 11:02:22 +0000 (12:02 +0100)]
lxc-user-nic: use cleanup macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agolxc-init: use cleanup macros
Christian Brauner [Sat, 9 Feb 2019 10:57:07 +0000 (11:57 +0100)]
lxc-init: use cleanup macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocgroup_utils: use __do_free
Christian Brauner [Sat, 9 Feb 2019 10:51:04 +0000 (11:51 +0100)]
cgroup_utils: use __do_free

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoattach: use __do_free
Christian Brauner [Sat, 9 Feb 2019 10:46:15 +0000 (11:46 +0100)]
attach: use __do_free

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoaf_unix: use __do_free
Christian Brauner [Sat, 9 Feb 2019 10:36:18 +0000 (11:36 +0100)]
af_unix: use __do_free

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agostart: move variable into tighter scope
Christian Brauner [Sat, 9 Feb 2019 10:32:45 +0000 (11:32 +0100)]
start: move variable into tighter scope

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2860 from stgraber/master
Christian Brauner [Sat, 16 Feb 2019 01:18:23 +0000 (02:18 +0100)]
Merge pull request #2860 from stgraber/master

mount: Allow over-mounting

5 years agomount: Cleanup allow over-mounting
Stéphane Graber [Sat, 16 Feb 2019 01:02:07 +0000 (20:02 -0500)]
mount: Cleanup allow over-mounting

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
5 years agoMerge pull request #2859 from stgraber/master
Christian Brauner [Sat, 16 Feb 2019 01:07:47 +0000 (02:07 +0100)]
Merge pull request #2859 from stgraber/master

mount: Allow over-mounting

5 years agomount: Allow over-mounting
Stéphane Graber [Sat, 16 Feb 2019 01:02:07 +0000 (20:02 -0500)]
mount: Allow over-mounting

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
5 years agoMerge pull request #2857 from brauner/2019-02-15/tweak_log
Stéphane Graber [Fri, 15 Feb 2019 23:21:33 +0000 (18:21 -0500)]
Merge pull request #2857 from brauner/2019-02-15/tweak_log

log: fixes

5 years agonetwork: do not log false friends
Christian Brauner [Fri, 15 Feb 2019 22:50:34 +0000 (23:50 +0100)]
network: do not log false friends

The netlink functions just return -1 and not specific negative errno values so
logging them doesn't make any sense.

Fixes: https://discuss.linuxcontainers.org/t/warning-in-the-container-log/4072/2
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoconf: do not log devpts umount2() failure
Christian Brauner [Fri, 15 Feb 2019 22:42:30 +0000 (23:42 +0100)]
conf: do not log devpts umount2() failure

We're not acting based on the return value so don't log anything.

Fixes: https://discuss.linuxcontainers.org/t/warning-in-the-container-log/4072/2
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2852 from brauner/2019-02-14/revert_simplify_argv_parsing
Stéphane Graber [Thu, 14 Feb 2019 15:58:09 +0000 (10:58 -0500)]
Merge pull request #2852 from brauner/2019-02-14/revert_simplify_argv_parsing

rexec: cmdline and environ parsing improvements

5 years agorexec: remove envp parsing in favour of environ
Christian Brauner [Thu, 14 Feb 2019 13:48:41 +0000 (14:48 +0100)]
rexec: remove envp parsing in favour of environ

My first attempt to simplify this and make it less costly focussed on
the way constructors are called. I was under the impression that the ELF
specification mandated that arg, argv, and actually even envp need to be
passed to functions located in the .init_array section (aka
"constructors"). Actually, the specifications is (cf. [2]):

SHT_INIT_ARRAY
This section contains an array of pointers to initialization functions,
as described in ``Initialization and Termination Functions'' in Chapter
5. Each pointer in the array is taken as a parameterless procedure with
a void return.

which means that this becomes a libc specific decision. Glibc passes
down those args, musl doesn't. So this approach can't work. However, we
can at least remove the environment parsing part based on POSIX since
[1] mandates that there should be an environ variable defined in
unistd.h which provides access to the environment. See also the relevant
Open Group specification [1].

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/
[2]: http://www.sco.com/developers/gabi/latest/ch4.sheader.html#init_array

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoRevert "rexec: remove needless /proc/cmdline parsing"
Christian Brauner [Thu, 14 Feb 2019 13:37:46 +0000 (14:37 +0100)]
Revert "rexec: remove needless /proc/cmdline parsing"

The ELF binary spec does specify in [1]:

SHT_INIT_ARRAY
This section contains an array of pointers to initialization functions,
as described in ``Initialization and Termination Functions'' in Chapter
5. Each pointer in the array is taken as a parameterless procedure with
a void return.

which means libcs other than glibc might not pass down argc and argv to
constructors.

This reverts commit 0c816b346788afa9d601766e31544fdcce67d780.

[1]: http://www.sco.com/developers/gabi/latest/ch4.sheader.html#init_array

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2850 from brauner/2019-02-13/simplify_argv_parsing
Stéphane Graber [Wed, 13 Feb 2019 22:25:05 +0000 (17:25 -0500)]
Merge pull request #2850 from brauner/2019-02-13/simplify_argv_parsing

rexec: remove needless /proc/cmdline parsing

5 years agorexec: remove needless /proc/cmdline parsing
Christian Brauner [Wed, 13 Feb 2019 22:08:11 +0000 (23:08 +0100)]
rexec: remove needless /proc/cmdline parsing

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2848 from 4383/improve-testing
Stéphane Graber [Tue, 12 Feb 2019 23:43:07 +0000 (18:43 -0500)]
Merge pull request #2848 from 4383/improve-testing

apparmore: Improve testing on apparmor python script

5 years agoapparmor: Improve testing on apparmor python script
Hervé Beraud [Tue, 12 Feb 2019 22:47:25 +0000 (23:47 +0100)]
apparmor: Improve testing on apparmor python script

Compare command output to already existing container-rules file

Signed-off-by: Hervé Beraud <hberaud@redhat.com>
5 years agoMerge pull request #2847 from 4383/improve-lxc-generator
Stéphane Graber [Tue, 12 Feb 2019 22:24:34 +0000 (17:24 -0500)]
Merge pull request #2847 from 4383/improve-lxc-generator

apparmor: catch config file opening error

5 years agoapparmor: catch config file opening error
Hervé Beraud [Tue, 12 Feb 2019 21:48:51 +0000 (22:48 +0100)]
apparmor: catch config file opening error

Improve config file error opening management
and improve main code block.

Execute this python script during CI to avoid
regressions

Signed-off-by: Hervé Beraud <hberaud@redhat.com>
5 years agoMerge pull request #2846 from brauner/2019-02-12/CVE-2019-5736
Stéphane Graber [Tue, 12 Feb 2019 17:14:19 +0000 (12:14 -0500)]
Merge pull request #2846 from brauner/2019-02-12/CVE-2019-5736

rexec: make rexecution opt-in for library callers

5 years agorexec: make rexecution opt-in for library callers
Christian Brauner [Tue, 12 Feb 2019 16:31:14 +0000 (17:31 +0100)]
rexec: make rexecution opt-in for library callers

We cannot rexecute the liblxc shared library unconditionally as this would
break most of our downstreams. Here are some scenarios:
- anyone performing a dlopen() on the shared library (e.g. users of the LXC
  Python bindings)
- LXD as it needs to know the absolute path to its own executable based on
  /proc/self/exe etc.

This commit makes the rexecution of liblxc conditional on whether the
LXC_MEMFD_REXEC environment variable is set or not. If it is then liblxc is
unconditionally rexecuted.

The only relevant attack vector exists for lxc-attach which we simply reexecute
unconditionally.

Reported-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2844 from brauner/2019-02-11/licensing+
Stéphane Graber [Mon, 11 Feb 2019 22:31:14 +0000 (17:31 -0500)]
Merge pull request #2844 from brauner/2019-02-11/licensing+

string_utils.h: fix wrong licensing

5 years agostring_utils.h: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 21:13:34 +0000 (22:13 +0100)]
string_utils.h: fix wrong licensing

liblxc has always been meant to be LGPLv2.1+ as reflected by the many
downstreams projects and bindings which are themselves under LGPLv2.1+ or other
licenses which would be incompatible with linking against a GPLv2+ library.

It's pretty normal for a library to be LGPL while binaries are GPL as a GPL
library would only ever be usable by other GPL-only projects, which isn't the
case for very many of the liblxc downstreams.

The issue here is really carelessness. None of those GPL headers were put there
intentionally, instead being wrongly copy/pasted from other parts of the
codebase which is indeed intended to be GPLv2+. This is also made clear in our
CONTRIBUTING file in this repository:

Licensing for new files:
------------------------

LXC is made of files shipped under a few different licenses.

Anything that ends up being part of the LXC library needs to be released
under LGPLv2.1+ or a license compatible with it (though the latter will
only be accepted for cases where the code originated elsewhere and was
imported into LXC).

Language bindings for the libraries need to be released under LGPLv2.1+.

Anything else (non-libraries) needs to be Free Software and needs to be
allowed to link with LGPLv2.1+ code (if needed). LXC upstream prefers
LGPLv2.1+ or GPLv2 for those.

When introducing a new file into the project, please make sure it has a
copyright header making clear under which license it's being released
and if it doesn't match the criteria described above, please explain
your decision on the lxc-devel mailing-list when submitting your patch.

This is intended to switch over files to LGPLv2.1+ to which end we have
collected ACKs from relevant people.
/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>
Fabrice Fontaine <fontaine.fabrice@gmail.com>
Josh Soref <jsoref@gmail.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Acked-by: Josh Soref <jsoref@gmail.com>
5 years agoMerge pull request #2843 from brauner/2019-02-11/fix_licensing_brauner
Stéphane Graber [Mon, 11 Feb 2019 16:58:23 +0000 (11:58 -0500)]
Merge pull request #2843 from brauner/2019-02-11/fix_licensing_brauner

fix licensing headers

5 years agosyscall_wrappers: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:30:26 +0000 (17:30 +0100)]
syscall_wrappers: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>
Aleksa Sarai <cyphar@cyphar.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoringbuf.h: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:29:31 +0000 (17:29 +0100)]
ringbuf.h: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agomemory_utils: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:27:45 +0000 (17:27 +0100)]
memory_utils: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agorexec: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:25:28 +0000 (17:25 +0100)]
rexec: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>
Aleksa Sarai <asarai@suse.de>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: Aleksa Sarai <cyphar@cyphar.com>
5 years agoapi_extensions: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:25:15 +0000 (17:25 +0100)]
api_extensions: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agofile_utils.h: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:33:18 +0000 (17:33 +0100)]
file_utils.h: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocompiler: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:23:52 +0000 (17:23 +0100)]
compiler: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoapi_extensions: fix wrong licensing
Christian Brauner [Mon, 11 Feb 2019 16:21:24 +0000 (17:21 +0100)]
api_extensions: fix wrong licensing

/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2841 from brauner/2019-02-11/fix_android
Stéphane Graber [Mon, 11 Feb 2019 15:27:57 +0000 (10:27 -0500)]
Merge pull request #2841 from brauner/2019-02-11/fix_android

include: add fexecve() for Android's Bionic

5 years agoinclude: add fexecve() for Android's Bionic
Christian Brauner [Mon, 11 Feb 2019 13:35:50 +0000 (14:35 +0100)]
include: add fexecve() for Android's Bionic

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoCVE-2019-5736 (runC): rexec callers as memfd
Christian Brauner [Sat, 26 Jan 2019 00:19:29 +0000 (01:19 +0100)]
CVE-2019-5736 (runC): rexec callers as memfd

Adam Iwaniuk and Borys Popławski discovered that an attacker can compromise the
runC host binary from inside a privileged runC container. As a result, this
could be exploited to gain root access on the host. runC is used as the default
runtime for containers with Docker, containerd, Podman, and CRI-O.

The attack can be made when attaching to a running container or when starting a
container running a specially crafted image.  For example, when runC attaches
to a container the attacker can trick it into executing itself. This could be
done by replacing the target binary inside the container with a custom binary
pointing back at the runC binary itself. As an example, if the target binary
was /bin/bash, this could be replaced with an executable script specifying the
interpreter path #!/proc/self/exe (/proc/self/exec is a symbolic link created
by the kernel for every process which points to the binary that was executed
for that process). As such when /bin/bash is executed inside the container,
instead the target of /proc/self/exe will be executed - which will point to the
runc binary on the host. The attacker can then proceed to write to the target
of /proc/self/exe to try and overwrite the runC binary on the host. However in
general, this will not succeed as the kernel will not permit it to be
overwritten whilst runC is executing. To overcome this, the attacker can
instead open a file descriptor to /proc/self/exe using the O_PATH flag and then
proceed to reopen the binary as O_WRONLY through /proc/self/fd/<nr> and try to
write to it in a busy loop from a separate process. Ultimately it will succeed
when the runC binary exits. After this the runC binary is compromised and can
be used to attack other containers or the host itself.

This attack is only possible with privileged containers since it requires root
privilege on the host to overwrite the runC binary. Unprivileged containers
with a non-identity ID mapping do not have the permission to write to the host
binary and therefore are unaffected by this attack.

LXC is also impacted in a similar manner by this vulnerability, however as the
LXC project considers privileged containers to be unsafe no CVE has been
assigned for this issue for LXC. Quoting from the
https://linuxcontainers.org/lxc/security/ project's Security information page:

"As privileged containers are considered unsafe, we typically will not consider
new container escape exploits to be security issues worthy of a CVE and quick
fix. We will however try to mitigate those issues so that accidental damage to
the host is prevented."

To prevent this attack, LXC has been patched to create a temporary copy of the
calling binary itself when it starts or attaches to containers. To do this LXC
creates an anonymous, in-memory file using the memfd_create() system call and
copies itself into the temporary in-memory file, which is then sealed to
prevent further modifications. LXC then executes this sealed, in-memory file
instead of the original on-disk binary. Any compromising write operations from
a privileged container to the host LXC binary will then write to the temporary
in-memory binary and not to the host binary on-disk, preserving the integrity
of the host LXC binary. Also as the temporary, in-memory LXC binary is sealed,
writes to this will also fail.

Note: memfd_create() was added to the Linux kernel in the 3.17 release.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Co-Developed-by: Alesa Sarai <asarai@suse.de>
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2839 from brauner/2019-02-10/handle_carriage_return
Stéphane Graber [Sun, 10 Feb 2019 23:21:49 +0000 (18:21 -0500)]
Merge pull request #2839 from brauner/2019-02-10/handle_carriage_return

parse: handle \r

5 years agoparse: handle \r
Christian Brauner [Sun, 10 Feb 2019 22:55:17 +0000 (23:55 +0100)]
parse: handle \r

Closes #2838.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2836 from brauner/2019-02-10/fix_cgfsng_driver
Wolfgang Bumiller [Sun, 10 Feb 2019 10:34:41 +0000 (11:34 +0100)]
Merge pull request #2836 from brauner/2019-02-10/fix_cgfsng_driver

cgroup: bugfixes

5 years agocgfsng: fix cgroup creation
Christian Brauner [Sun, 10 Feb 2019 09:53:06 +0000 (10:53 +0100)]
cgfsng: fix cgroup creation

When cgroup creation failed we reset container_cgroup to NULL to avoid
issues with __cleanup__. Fix that logic:
- add steal_ptr() based on take_ptr()
- move stealing the pointer out of the loop

lxc ctImport 20190210050705.858 DEBUG    network - network.c:instantiate_veth:202 - Instantiated veth "vethGQMH7I/vethSPXNL3", index is "272"
lxc ctImport 20190210050705.858 ERROR    cgfsng - cgroups/cgfsng.c:mkdir_eexist_on_last:1262 - File exists - Failed to create directory "/sys/fs/cgroup/unified//lxc.payload/ctImport-0"
lxc ctImport 20190210050705.858 ERROR    cgfsng - cgroups/cgfsng.c:container_create_path_for_hierarchy:1302 - Failed to create cgroup "/sys/fs/cgroup/unified//lxc.payload/ctImport-0"
lxc ctImport 20190210050705.858 ERROR    cgfsng - cgroups/cgfsng.c:cgfsng_payload_create:1431 - Failed to create cgroup "/sys/fs/cgroup/unified//lxc.payload/ctImport-0"
lxc ctImport 20190210050705.858 INFO     cgfsng - cgroups/cgfsng.c:cgfsng_payload_create:1441 - The container uses "lxc.payload/ctImport-0" as cgroup
lxc ctImport 20190210050705.858 ERROR    cgfsng - cgroups/cgfsng.c:mkdir_eexist_on_last:1262 - File exists - Failed to create directory "/sys/fs/cgroup/unified/"
lxc ctImport 20190210050705.858 ERROR    cgfsng - cgroups/cgfsng.c:container_create_path_for_hierarchy:1302 - Failed to create cgroup "/sys/fs/cgroup/unified/"
lxc ctImport 20190210050705.858 ERROR    cgfsng - cgroups/cgfsng.c:cgfsng_payload_create:1431 - Failed to create cgroup "/sys/fs/cgroup/unified/"
lxc ctImport 20190210050705.858 INFO     cgfsng - cgroups/cgfsng.c:cgfsng_payload_create:1441 - The container uses "(null)" as cgroup

Fixes: d97919abf22 ("cgroups: partially switch to cleanup macros")
Reported-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocgfsng: coding style for cgfsng_payload_create()
Christian Brauner [Sun, 10 Feb 2019 09:52:45 +0000 (10:52 +0100)]
cgfsng: coding style for cgfsng_payload_create()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocgfsng: coding style for cgfsng_monitor_create()
Christian Brauner [Sun, 10 Feb 2019 09:51:43 +0000 (10:51 +0100)]
cgfsng: coding style for cgfsng_monitor_create()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2832 from brauner/2019-02-08/add_coccinelle
Stéphane Graber [Sat, 9 Feb 2019 21:58:36 +0000 (16:58 -0500)]
Merge pull request #2832 from brauner/2019-02-08/add_coccinelle

coccinelle support

5 years agoMerge pull request #2829 from brauner/2019-02-08/capabilities
Stéphane Graber [Sat, 9 Feb 2019 21:57:01 +0000 (16:57 -0500)]
Merge pull request #2829 from brauner/2019-02-08/capabilities

caps: check uid and euid

5 years agococcinelle: use standard exit identifiers
Christian Brauner [Sat, 9 Feb 2019 10:23:54 +0000 (11:23 +0100)]
coccinelle: use standard exit identifiers

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agococcinelle: s/while({1,true})/for(;;)/
Christian Brauner [Fri, 8 Feb 2019 22:57:06 +0000 (23:57 +0100)]
coccinelle: s/while({1,true})/for(;;)/

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agococcinelle: add coccinelle support
Christian Brauner [Fri, 8 Feb 2019 22:56:51 +0000 (23:56 +0100)]
coccinelle: add coccinelle support

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2833 from brauner/2019-02-09/bugfixes
Christian Brauner [Sat, 9 Feb 2019 10:03:42 +0000 (11:03 +0100)]
Merge pull request #2833 from brauner/2019-02-09/bugfixes

bugfixes

5 years agolxc-init: exit with error on wait failure
Christian Brauner [Sat, 9 Feb 2019 00:35:44 +0000 (01:35 +0100)]
lxc-init: exit with error on wait failure

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agostart: prevent signed-issues
Christian Brauner [Sat, 9 Feb 2019 00:33:18 +0000 (01:33 +0100)]
start: prevent signed-issues

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocgfsng: remove unnecessary check
Christian Brauner [Sat, 9 Feb 2019 00:31:52 +0000 (01:31 +0100)]
cgfsng: remove unnecessary check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocommands: remove unnecessary check
Christian Brauner [Sat, 9 Feb 2019 00:28:52 +0000 (01:28 +0100)]
commands: remove unnecessary check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2827 from brauner/2019-02-07/auto_cleanup
Serge Hallyn [Fri, 8 Feb 2019 21:57:37 +0000 (15:57 -0600)]
Merge pull request #2827 from brauner/2019-02-07/auto_cleanup

cgroups: partially switch to cleanup macros

5 years agocaps: check uid and euid
Christian Brauner [Fri, 8 Feb 2019 14:11:46 +0000 (15:11 +0100)]
caps: check uid and euid

When we are running inside of a user namespace getuid() will return a
non-zero uid. So let's check euid as well to make sure we correctly drop
capabilities

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agocgroups: partially switch to cleanup macros
Christian Brauner [Thu, 7 Feb 2019 08:15:09 +0000 (09:15 +0100)]
cgroups: partially switch to cleanup macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2825 from brauner/lxc/master
Christian Brauner [Wed, 6 Feb 2019 11:24:48 +0000 (12:24 +0100)]
Merge pull request #2825 from brauner/lxc/master

README: add LGTM

5 years agoREADME: add LGTM
Christian Brauner [Wed, 6 Feb 2019 11:23:17 +0000 (12:23 +0100)]
README: add LGTM

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoMerge pull request #2821 from brauner/2019-02-05/remove_stack_allocation
Wolfgang Bumiller [Wed, 6 Feb 2019 11:10:48 +0000 (12:10 +0100)]
Merge pull request #2821 from brauner/2019-02-05/remove_stack_allocation

tree-wide: wipe alloca() from the codebase

5 years agolxc-unshare: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:47:18 +0000 (07:47 +0100)]
lxc-unshare: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agooverlay: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:46:13 +0000 (07:46 +0100)]
overlay: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agorbd: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:44:13 +0000 (07:44 +0100)]
rbd: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agonbd: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:42:50 +0000 (07:42 +0100)]
nbd: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agolvm: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:39:51 +0000 (07:39 +0100)]
lvm: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoloop: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:38:02 +0000 (07:38 +0100)]
loop: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agoterminal: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:26:19 +0000 (07:26 +0100)]
terminal: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agostring_utils: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:30:00 +0000 (07:30 +0100)]
string_utils: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agostorage: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:32:21 +0000 (07:32 +0100)]
storage: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agostart: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:25:12 +0000 (07:25 +0100)]
start: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agopam_cgfs: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:33:48 +0000 (07:33 +0100)]
pam_cgfs: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agonetwork: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:27:29 +0000 (07:27 +0100)]
network: remove stack allocations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agonamespace: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:23:19 +0000 (07:23 +0100)]
namespace: remove stack allocations

Switch to a static stack instead of allocating a new one. There's really
no point in doing all of the dance to get the current pagesize.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
5 years agomonitor: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:31:16 +0000 (07:31 +0100)]
monitor: remove stack allocations

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