Commit Graph

8686 Commits

Author SHA1 Message Date
Christian Brauner
4aa90f6012
[V2] rexec: handle legacy kernels
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 19:51:52 +01:00
Stéphane Graber
7cf89ee88d
Revert "rexec: handle legacy kernels"
Broke Android

This reverts commit 8f350e637c.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2019-02-18 12:15:30 -05:00
Stéphane Graber
4d8a34c31c
Merge pull request #2862 from brauner/2019-02-17/save_rexec
cleanup macros and rexec fixes
2019-02-18 11:56:44 -05:00
Christian Brauner
fed8112d04
rexec: use __do_close_prot_errno
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:14 +01:00
Christian Brauner
8f350e637c
rexec: handle legacy kernels
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:14 +01:00
Christian Brauner
2a30bdea60
commands: cleanup macros lxc_cmd_init()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:14 +01:00
Christian Brauner
c13e711119
commands: cleanup macros lxc_cmd_init
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
4c2effceb4
commands: cleanup macros lxc_cmd_accept()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
cd889e57a4
commands: cleanup macros lxc_cmd_add_state_client
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
c34ff11978
commands: cleanup macros lxc_cmd()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
e96f929188
commands: use __do_close_prot_errno
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
e236fe05d1
memory_utils: introduce __do_close_prot_errno
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
4101805bb2
macro: introduce steal_fd()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
8259d86d97
commands: cleanup macros in lxc_cmd_console()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-18 15:24:13 +01:00
Christian Brauner
2ebc7bde97
commands: move declaration into tighter scope
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:21:09 +01:00
Christian Brauner
e8cc83897a
lxc-usernsexec: use cleanup macros
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:44 +01:00
Christian Brauner
5c8d235259
lxc-user-nic: use cleanup macros
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:44 +01:00
Christian Brauner
3cf7d8c2b8
lxc-init: use cleanup macros
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:44 +01:00
Christian Brauner
57e7625005
cgroup_utils: use __do_free
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:44 +01:00
Christian Brauner
cd8f5663ab
attach: use __do_free
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:44 +01:00
Christian Brauner
83c11f1d04
af_unix: use __do_free
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:44 +01:00
Christian Brauner
d85617bc67
start: move variable into tighter scope
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-17 14:13:42 +01:00
Christian Brauner
7a8959d572
Merge pull request #2860 from stgraber/master
mount: Allow over-mounting
2019-02-16 02:18:23 +01:00
Stéphane Graber
71521317b2
mount: Cleanup allow over-mounting
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2019-02-15 20:14:34 -05:00
Christian Brauner
eba282e4d8
Merge pull request #2859 from stgraber/master
mount: Allow over-mounting
2019-02-16 02:07:47 +01:00
Stéphane Graber
c00d0e3b2a
mount: Allow over-mounting
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2019-02-15 20:02:07 -05:00
Stéphane Graber
4d3d037a98
Merge pull request #2857 from brauner/2019-02-15/tweak_log
log: fixes
2019-02-15 18:21:33 -05:00
Christian Brauner
24548539af
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>
2019-02-15 23:53:45 +01:00
Christian Brauner
29a7b484ff
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>
2019-02-15 23:53:32 +01:00
Stéphane Graber
2cd6412251
Merge pull request #2852 from brauner/2019-02-14/revert_simplify_argv_parsing
rexec: cmdline and environ parsing improvements
2019-02-14 10:58:09 -05:00
Christian Brauner
cee55b59cd
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>
2019-02-14 16:10:07 +01:00
Christian Brauner
7a80606d7b
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 0c816b3467.

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

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-14 14:37:46 +01:00
Stéphane Graber
257e396bed
Merge pull request #2850 from brauner/2019-02-13/simplify_argv_parsing
rexec: remove needless /proc/cmdline parsing
2019-02-13 17:25:05 -05:00
Christian Brauner
0c816b3467
rexec: remove needless /proc/cmdline parsing
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-13 23:09:18 +01:00
Stéphane Graber
33257e9792
Merge pull request #2848 from 4383/improve-testing
apparmore: Improve testing on apparmor python script
2019-02-12 18:43:07 -05:00
Hervé Beraud
069d8e86c1 apparmor: Improve testing on apparmor python script
Compare command output to already existing container-rules file

Signed-off-by: Hervé Beraud <hberaud@redhat.com>
2019-02-12 23:58:43 +01:00
Stéphane Graber
1530ced383
Merge pull request #2847 from 4383/improve-lxc-generator
apparmor: catch config file opening error
2019-02-12 17:24:34 -05:00
Hervé Beraud
c70de0eabb 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>
2019-02-12 23:09:04 +01:00
Stéphane Graber
b091c341d5
Merge pull request #2846 from brauner/2019-02-12/CVE-2019-5736
rexec: make rexecution opt-in for library callers
2019-02-12 12:14:19 -05:00
Christian Brauner
d3a9befc86
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>
2019-02-12 17:58:34 +01:00
Stéphane Graber
b88ccedc1e
Merge pull request #2844 from brauner/2019-02-11/licensing+
string_utils.h: fix wrong licensing
2019-02-11 17:31:14 -05:00
Christian Brauner
84fa5acacc
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>
2019-02-11 23:10:32 +01:00
Stéphane Graber
9581e69761
Merge pull request #2843 from brauner/2019-02-11/fix_licensing_brauner
fix licensing headers
2019-02-11 11:58:23 -05:00
Christian Brauner
7043a15df3
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>
2019-02-11 17:35:08 +01:00
Christian Brauner
c423a0a7d8
ringbuf.h: fix wrong licensing
/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-11 17:35:08 +01:00
Christian Brauner
cd4a865dd6
memory_utils: fix wrong licensing
/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-11 17:35:08 +01:00
Christian Brauner
2b3153a882
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>
2019-02-11 17:35:07 +01:00
Christian Brauner
3877934c7a
api_extensions: fix wrong licensing
/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-11 17:35:07 +01:00
Christian Brauner
6aae19f7c8
file_utils.h: fix wrong licensing
/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-11 17:33:18 +01:00
Christian Brauner
b80e01bda3
compiler: fix wrong licensing
/* Affected People */
Christian Brauner <christian.brauner@ubuntu.com>

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-11 17:23:52 +01:00