]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 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>
6 years agolxccontainer: remove stack allocations
Christian Brauner [Tue, 5 Feb 2019 06:19:56 +0000 (07:19 +0100)] 
lxccontainer: remove stack allocations

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

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

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

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

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

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

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

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wnested-externs hardening
Christian Brauner [Tue, 5 Feb 2019 22:50:43 +0000 (23:50 +0100)] 
compiler: -Wnested-externs hardening

Warn if an extern declaration is encountered within a function.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wdate-time hardening
Christian Brauner [Tue, 5 Feb 2019 22:49:48 +0000 (23:49 +0100)] 
compiler: -Wdate-time hardening

Warn when macros __TIME__, __DATE__ or __TIMESTAMP__ are encountered as
they might prevent bit-wise-identical reproducible compilations.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Werror=shift-overflow=2 hardening
Christian Brauner [Tue, 5 Feb 2019 22:48:32 +0000 (23:48 +0100)] 
compiler: -Werror=shift-overflow=2 hardening

Warn about left shift overflows. This warning is enabled by default in
C99 and C++11 modes (and newer).

-Wshift-overflow=2
This warning level also warns about left-shifting 1 into the sign bit,
unless C++14 mode (or newer) is active.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Werror=shift-count-overflow hardening
Christian Brauner [Tue, 5 Feb 2019 22:47:31 +0000 (23:47 +0100)] 
compiler: -Werror=shift-count-overflow hardening

Warn if shift count >= width of type.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: fix -fstack-protector-strong
Christian Brauner [Tue, 5 Feb 2019 22:44:20 +0000 (23:44 +0100)] 
compiler: fix -fstack-protector-strong

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -fdiagnostics-show-option
Christian Brauner [Tue, 5 Feb 2019 22:25:19 +0000 (23:25 +0100)] 
compiler: -fdiagnostics-show-option

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Werror=overflow hardening
Christian Brauner [Tue, 5 Feb 2019 22:21:43 +0000 (23:21 +0100)] 
compiler: -Werror=overflow hardening

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wendif-labels hardening
Christian Brauner [Tue, 5 Feb 2019 22:15:05 +0000 (23:15 +0100)] 
compiler: -Wendif-labels hardening

Do not warn whenever an #else or an #endif are followed by text.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wshadow hardening
Christian Brauner [Tue, 5 Feb 2019 19:56:08 +0000 (20:56 +0100)] 
compiler: -Wshadow hardening

Warn whenever a local variable or type declaration shadows another
variable, parameter, type, class member (in C++), or instance variable
(in Objective-C) or whenever a built-in function is shadowed.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: set -Wimplicit-fallthrough to 5
Christian Brauner [Tue, 5 Feb 2019 19:54:33 +0000 (20:54 +0100)] 
compiler: set -Wimplicit-fallthrough to 5

-Wimplicit-fallthrough=5 doesn’t recognize any comments as fallthrough
comments, only attributes disable the warning.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wformat=2 hardening
Christian Brauner [Tue, 5 Feb 2019 19:51:50 +0000 (20:51 +0100)] 
compiler: -Wformat=2 hardening

Enable -Wformat plus additional format checks. Currently equivalent to
-Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Werror=incompatible-pointer-types
Christian Brauner [Tue, 5 Feb 2019 19:49:59 +0000 (20:49 +0100)] 
compiler: -Werror=incompatible-pointer-types

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Werror=return-type hardening
Christian Brauner [Tue, 5 Feb 2019 19:48:45 +0000 (20:48 +0100)] 
compiler: -Werror=return-type hardening

Warn whenever a function is defined with a return type that defaults to
int. Also warn about any return statement with no return value in a
function whose return type is not void (falling off the end of the
function body is considered returning without a value).

For C only, warn about a return statement with an expression in a
function whose return type is void, unless the expression type is also
void. As a GNU extension, the latter case is accepted without a warning
unless -Wpedantic is used.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wsuggest-attribute=noreturn hardening
Christian Brauner [Tue, 5 Feb 2019 19:44:57 +0000 (20:44 +0100)] 
compiler: -Wsuggest-attribute=noreturn hardening

Warn about functions that might be candidates for attributes pure, const
or noreturn or malloc.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wfloat-equal hardening
Christian Brauner [Tue, 5 Feb 2019 19:43:52 +0000 (20:43 +0100)] 
compiler: -Wfloat-equal hardening

Warn if floating-point values are used in equality comparisons.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Winit-self hardening
Christian Brauner [Tue, 5 Feb 2019 19:43:00 +0000 (20:43 +0100)] 
compiler: -Winit-self hardening

Warn about uninitialized variables that are initialized with themselves.
Note this option can only be used with the -Wuninitialized option.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wold-style-definition hardening
Christian Brauner [Tue, 5 Feb 2019 19:33:40 +0000 (20:33 +0100)] 
compiler: -Wold-style-definition hardening

Warn if an old-style function definition is used. A warning is given
even if there is a previous prototype.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wmissing-include-dirs hardening
Christian Brauner [Tue, 5 Feb 2019 19:31:20 +0000 (20:31 +0100)] 
compiler: -Wmissing-include-dirs hardening

Warn if a user-supplied include directory does not exist.

This already surfaced a bug that is fixed by this commit.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: -Wlogical-op hardening
Christian Brauner [Tue, 5 Feb 2019 19:29:21 +0000 (20:29 +0100)] 
compiler: -Wlogical-op hardening

Warn about suspicious uses of logical operators in expressions.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agofix rpm packaging for bash completion directory.
tomponline [Tue, 5 Feb 2019 17:10:20 +0000 (17:10 +0000)] 
fix rpm packaging for bash completion directory.

Closed #1825

Signed-off-by: tomponline <tomp@tomp.uk>
6 years agoMore accurate error msg for template file
Rachid Koucha [Tue, 29 Jan 2019 11:20:46 +0000 (12:20 +0100)] 
More accurate error msg for template file

When calling lxc-create, if the template exists but is not executable, we end with the following error messages which make believe that the template file does not exist when it is merely a execute access problem:

lxc-create: ctn00: utils.c: get_template_path: 918 No such file or directory - bad template: /.../lxc-busybox
lxc-create: ctn00: lxccontainer.c: do_lxcapi_create: 1786 Unknown template "/.../lxc-busybox"
lxc-create: ctn00: tools/lxc_create.c: main: 327 Failed to create container ctn00

Actually internally the errno is lost as the following code triggers a useless access to (strace output):

access("/.../lxc-busybox", X_OK) = -1 ENOENT (No such file or directory)

With the above fix, we get a more explicit error message when the template file is missing the "execute" bit:

lxc-create: bbc: utils.c: get_template_path: 917 Permission denied - Bad template pathname: /tmp/azerty
lxc-create: bbc: lxccontainer.c: do_lxcapi_create: 1816 Unknown template "/tmp/azerty"
lxc-create: bbc: tools/lxc_create.c: main: 331 Failed to create container bbc

With the above fix, we get a more explicit error message when the pathname of the template file is incorrect:

lxc-create: bbc: utils.c: get_template_path: 917 No such file or directory - Bad template pathname: /tmp/qwerty
lxc-create: bbc: lxccontainer.c: do_lxcapi_create: 1816 Unknown template "/tmp/qwerty"
lxc-create: bbc: tools/lxc_create.c: main: 331 Failed to create container bbc

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
6 years agoprlimit: remove deprecated and unneeded header
Christian Brauner [Sun, 27 Jan 2019 22:05:47 +0000 (23:05 +0100)] 
prlimit: remove deprecated and unneeded header

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocompiler: remove deprecated and unneeded header
Christian Brauner [Sun, 27 Jan 2019 22:02:49 +0000 (23:02 +0100)] 
compiler: remove deprecated and unneeded header

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years ago/etc/resolv.conf grows indefinitely
Rachid Koucha [Sun, 27 Jan 2019 12:46:48 +0000 (13:46 +0100)] 
/etc/resolv.conf grows indefinitely

This file grows indefinitely : upon each DHCP lease renew,
the "nameserver ..dns..." line is added at the end of the file.
Make a "grep" in the file to make sure that the same line
does not already exist.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
6 years agoCreate /var/run
Rachid Koucha [Sun, 27 Jan 2019 11:23:58 +0000 (12:23 +0100)] 
Create /var/run

Some programs like "who" need this directory
to work (this permits the of /var/run/utmp file).

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
6 years agoUse BUSYBOX_EXE variable in configure_busybox()
Rachid Koucha [Sun, 27 Jan 2019 10:51:57 +0000 (11:51 +0100)] 
Use BUSYBOX_EXE variable in configure_busybox()

As "which busybox" is stored in BUSYBOX_EXE
global variable at startup, use it wherever it is
needed.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
6 years agoconf: check for successful mount entry parse
Christian Brauner [Sun, 27 Jan 2019 01:22:43 +0000 (02:22 +0100)] 
conf: check for successful mount entry parse

Since liblxc is completely in control of the mount entry file we should
only consider a parse successful when EOF is reached.

Closes #2798.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoInstallation of default.script for udhcpc
Rachid Koucha [Sun, 27 Jan 2019 02:38:36 +0000 (03:38 +0100)] 
Installation of default.script for udhcpc

The busybox template installs default.script in /usr/share/udhcpc/.
But the pathname of "default.script" may vary from one busybox
build to another. As the pathname is displayed in udhcpc's help,
grab it from it.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
6 years agoAvoid risk of "too far memory read"
Rachid Koucha [Sat, 26 Jan 2019 23:10:39 +0000 (00:10 +0100)] 
Avoid risk of "too far memory read"

As we call "lxc_add_state_client(fd, handler, (lxc_state_t *)req->data)"
which supposes that the last parameter is a table of MAX_STATE
entries when calling memcpy():
memcpy(newclient->states, states, sizeof(newclient->states))

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
6 years agoHandle alternative loop device location on Android
ondra [Fri, 11 Jan 2019 14:45:38 +0000 (14:45 +0000)] 
Handle alternative loop device location on Android

Signed-off-by: ondra <ondrak@localhost.localdomain>
6 years agoFixing hooks functionality Android where 'sh' is placed under /system/bin
ondra [Fri, 11 Jan 2019 16:42:13 +0000 (16:42 +0000)] 
Fixing hooks functionality Android where 'sh' is placed under /system/bin

Signed-off-by: ondra <ondrak@localhost.localdomain>
6 years agoFix memory leak in cgroup_exit
LiFeng [Thu, 17 Jan 2019 10:48:16 +0000 (05:48 -0500)] 
Fix memory leak in cgroup_exit

Add free memory pointed by struct cgroup_ops *ops

Signed-off-by: LiFeng <lifeng68@huawei.com>
6 years agoconf.c: fix memory leak and mount error
t00416110 [Thu, 17 Jan 2019 09:16:22 +0000 (17:16 +0800)] 
conf.c: fix memory leak and mount error

1. cleanup namespace memory
2. fix bug when ro mount not setted, mount propagation will be skipped.

Signed-off-by: t00416110 <tanyifeng1@huawei.com>
6 years agoRevert "conf: remove extra MS_BIND with sysfs:mixed"
Wolfgang Bumiller [Thu, 17 Jan 2019 08:16:16 +0000 (09:16 +0100)] 
Revert "conf: remove extra MS_BIND with sysfs:mixed"

This reverts commit 51a922baf724689ff3a0df938ca8975601c9c815.

The above commit confuses the mountall unit of privileged
Ubuntu 14.04 containers at startup so that they cannot
finish booting.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 years agonetwork: prefix veth interface name with uid info
hn [Tue, 8 Jan 2019 20:23:41 +0000 (21:23 +0100)] 
network: prefix veth interface name with uid info

Signed-off-by: Hajo Noerenberg <hajo-github@noerenberg.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agostart: handle missing CLONE_NEWCGROUP
Christian Brauner [Thu, 10 Jan 2019 12:35:42 +0000 (13:35 +0100)] 
start: handle missing CLONE_NEWCGROUP

If cgroup namespaces are not supported we should just record it in the
log and move on.

Cc: Ondrej Kubik <ondrej.kubik@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoFixing compile error when compiling for android
Ondrej Kubik [Tue, 8 Jan 2019 17:00:36 +0000 (17:00 +0000)] 
Fixing compile error when compiling for android

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
6 years agofix: unprivileged veth devices (e.g. vethFWABHX) never contain 'Z' character in the...
hn [Mon, 7 Jan 2019 18:42:02 +0000 (19:42 +0100)] 
fix: unprivileged veth devices (e.g. vethFWABHX) never contain 'Z' character in the randomly generated device name part because for modulo one does not need to substract 1 from strlen().

Signed-off-by: Hajo Noerenberg <hajo-github@noerenberg.de>
6 years agolxccontainer: fix container copy
Christian Brauner [Mon, 7 Jan 2019 12:37:06 +0000 (13:37 +0100)] 
lxccontainer: fix container copy

We need to strip the prefix from the container's source path before
trying to update the file.

Closes #2380.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoRevert "Set c to NULL after freeing it"
S.Çağlar Onur [Sat, 5 Jan 2019 20:22:17 +0000 (12:22 -0800)] 
Revert "Set c to NULL after freeing it"

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
6 years agoconf: use SYSERROR on lxc_write_to_file errors
Wolfgang Bumiller [Fri, 4 Jan 2019 11:05:49 +0000 (12:05 +0100)] 
conf: use SYSERROR on lxc_write_to_file errors

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
6 years agoSet c to NULL after freeing it
S.Çağlar Onur [Wed, 26 Dec 2018 19:18:31 +0000 (11:18 -0800)] 
Set c to NULL after freeing it

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
6 years agoterminal: remove sigwinch command
Christian Brauner [Thu, 13 Dec 2018 14:44:36 +0000 (15:44 +0100)] 
terminal: remove sigwinch command

SIGWINCH is handled in lxc_terminal_signalfd_cb().

I cannot for the life of me figure out what this is supposed to do.
Afaict, it scans a global list that is totally unnecessary and also
let's say you have 100 ttys and for a single one SIGWINCH is sent. In
that case the whole list is walked and two ioctl()s are performed: one
to get window size one to set window size. For 99 of them the window
size hasn't changed.
If we see issues we can revert!

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agotools: add newline to lxc-cgroup output
Christian Brauner [Wed, 12 Dec 2018 10:47:10 +0000 (11:47 +0100)] 
tools: add newline to lxc-cgroup output

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agofix lxc-cgroup not giving output
Oguz Bektas [Wed, 12 Dec 2018 09:26:36 +0000 (10:26 +0100)] 
fix lxc-cgroup not giving output

lxc-cgroup fails to provide any output since the latest version, this
should fix it

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
6 years agostorage: remove unused function
Christian Brauner [Tue, 11 Dec 2018 10:36:54 +0000 (11:36 +0100)] 
storage: remove unused function

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoconfigure.ac: fix build without stack-protector
Fabrice Fontaine [Tue, 4 Dec 2018 07:40:05 +0000 (08:40 +0100)] 
configure.ac: fix build without stack-protector

Compiler based hardening (including -fstack-protector-strong) are
enabled since version 3.0.3 and
https://github.com/lxc/lxc/commit/2268c27754152aa538db2c9e3753d72d19bcd17a

However, some compilers could missed the needed library (-lssp or
-lssp_nonshared) at linking step so use ax_check_link_flag instead of
ax_check_compile_flag

Fixes:
 - http://autobuild.buildroot.org/results/0b90e7dca2984652842832a41abad93ac49a9b86

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
6 years agostringutils: include stdarg for va_list
Fabrice Fontaine [Mon, 3 Dec 2018 21:18:16 +0000 (22:18 +0100)] 
stringutils: include stdarg for va_list

Fixes:
 - http://autobuild.buildroot.org/results/0b90e7dca2984652842832a41abad93ac49a9b86

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
6 years agoAdd template-options to help output
Adam Kasztenny [Fri, 30 Nov 2018 17:34:34 +0000 (12:34 -0500)] 
Add template-options to help output

Copied from the [manpage](https://github.com/lxc/lxc/blob/9e42c1e3f102be48be9014e1ecbacc2a57446e20/doc/lxc-create.sgml.in#L175).

Signed-off-by: Adam Kasztenny <adamkasztenny@gmail.com>
6 years agofix install error when using --disable-commands option
2xsec [Fri, 30 Nov 2018 06:31:31 +0000 (15:31 +0900)] 
fix install error when using --disable-commands option

Signed-off-by: 2xsec <dh48.jeong@samsung.com>
6 years agolxc-usernsexec: fix default map functionality
Cameron Nemo [Thu, 29 Nov 2018 03:42:29 +0000 (19:42 -0800)] 
lxc-usernsexec: fix default map functionality

* Place NULL bytes at the end of strings so that
  lxc_safe_ulong() can parse them correctly

* Only free the newly created id_map on error,
  to avoid passing garbage to lxc_map_ids()

Signed-off-by: Cameron Nemo <camerontnorman@gmail.com>
6 years agorexec: handle old kernels
Christian Brauner [Mon, 18 Feb 2019 22:36:03 +0000 (23:36 +0100)] 
rexec: handle old kernels

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 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>
6 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: Aleksa Sarai <asarai@suse.de>
Acked-by: Serge Hallyn <serge@hallyn.com>
6 years agoMerge pull request #2830 from brauner/2019-02-08/capabilities_stable-3.0
Stéphane Graber [Sat, 9 Feb 2019 21:57:20 +0000 (16:57 -0500)] 
Merge pull request #2830 from brauner/2019-02-08/capabilities_stable-3.0

caps: check uid and euid

6 years agocaps: check uid and euid 2830/head
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>
6 years agoMerge pull request #2772 from brauner/2018-01-09/fix_cgroup_deletion_stable-3.0
Stéphane Graber [Mon, 7 Jan 2019 23:33:26 +0000 (00:33 +0100)] 
Merge pull request #2772 from brauner/2018-01-09/fix_cgroup_deletion_stable-3.0

cgfsng: do not free container_full_path on error

6 years agocgfsng: do not free container_full_path on error 2772/head
Christian Brauner [Mon, 7 Jan 2019 15:10:44 +0000 (16:10 +0100)] 
cgfsng: do not free container_full_path on error

Closes #2741.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoMerge pull request #2758 from Blub/2018-12-17/stable-3.0/apparmor-bind-remount
Christian Brauner [Mon, 17 Dec 2018 11:06:57 +0000 (12:06 +0100)] 
Merge pull request #2758 from Blub/2018-12-17/stable-3.0/apparmor-bind-remount

apparmor: allow various remount,bind options

6 years agoapparmor: allow various remount,bind options 2758/head
Wolfgang Bumiller [Thu, 15 Nov 2018 10:51:34 +0000 (11:51 +0100)] 
apparmor: allow various remount,bind options

RW bind mounts need to be restricted for some paths in
order to avoid MAC restriction bypasses, but read-only bind
mounts shouldn't have that problem.

Additionally, combinations of 'nosuid', 'nodev' and
'noexec' flags shouldn't be a problem either and are
required with newer systemd versions, so let's allow those
as long as they're combined with 'ro,remount,bind'.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
(cherry picked from commit e6ec0a9e71aa68c9fd67c691a62aaae87e356cef)

6 years agoRelease LXC 3.0.3 lxc-3.0.3
Stéphane Graber [Thu, 22 Nov 2018 23:07:50 +0000 (18:07 -0500)] 
Release LXC 3.0.3

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
6 years agoMerge pull request #2735 from brauner/lxc/stable-3.0
Stéphane Graber [Thu, 22 Nov 2018 22:36:39 +0000 (17:36 -0500)] 
Merge pull request #2735 from brauner/lxc/stable-3.0

start: don't call cgroup_exit() twice

6 years agostart: don't call cgroup_exit() twice 2735/head
Christian Brauner [Thu, 22 Nov 2018 22:19:09 +0000 (23:19 +0100)] 
start: don't call cgroup_exit() twice

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agocgfsng: remove freezer requirement
Christian Brauner [Tue, 20 Nov 2018 17:06:43 +0000 (18:06 +0100)] 
cgfsng: remove freezer requirement

The freezer controller has been made optional in all other codepaths so
don't require it.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
6 years agoautotools: fix lxc-{create,copy} build
Radostin Stoyanov [Tue, 20 Nov 2018 01:10:57 +0000 (01:10 +0000)] 
autotools: fix lxc-{create,copy} build

After commit 2b670df lxc-create and lxc-copy fails with "undefined
symbol: get_fssize".

Closes #2730

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>