Commit Graph

8173 Commits

Author SHA1 Message Date
Christian Brauner
c74da4abd2
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: d97919abf2 ("cgroups: partially switch to cleanup macros")
Reported-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-10 10:58:04 +01:00
Christian Brauner
d99d5c935a
cgfsng: coding style for cgfsng_payload_create()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-10 10:57:53 +01:00
Christian Brauner
f2668eea50
cgfsng: coding style for cgfsng_monitor_create()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-10 10:57:41 +01:00
Christian Brauner
f57860aca9
Merge pull request #2833 from brauner/2019-02-09/bugfixes
bugfixes
2019-02-09 11:03:42 +01:00
Christian Brauner
6425271d04
lxc-init: exit with error on wait failure
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-09 01:35:44 +01:00
Christian Brauner
f7a0c6ee2a
start: prevent signed-issues
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-09 01:33:18 +01:00
Christian Brauner
0dbdb99e3b
cgfsng: remove unnecessary check
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-09 01:31:52 +01:00
Christian Brauner
6403a6671c
commands: remove unnecessary check
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-09 01:28:52 +01:00
Serge Hallyn
884b37d091
Merge pull request #2827 from brauner/2019-02-07/auto_cleanup
cgroups: partially switch to cleanup macros
2019-02-08 15:57:37 -06:00
Christian Brauner
d97919abf2
cgroups: partially switch to cleanup macros
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-08 13:40:17 +01:00
Christian Brauner
42bd57bdbd
Merge pull request #2825 from brauner/lxc/master
README: add LGTM
2019-02-06 12:24:48 +01:00
Christian Brauner
a62cf72a8b
README: add LGTM
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 12:23:17 +01:00
Wolfgang Bumiller
d6a4505542
Merge pull request #2821 from brauner/2019-02-05/remove_stack_allocation
tree-wide: wipe alloca() from the codebase
2019-02-06 12:10:48 +01:00
Christian Brauner
57e2af15ed
lxc-unshare: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
e2c6671d17
overlay: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
3206805085
rbd: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
9371d3f2b6
nbd: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
007bb915d5
lvm: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
6b4e204c7b
loop: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
2530ba9597
terminal: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:58 +01:00
Christian Brauner
97f35ce6f8
string_utils: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
643c9ec994
storage: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
4ffeaf2766
start: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
6421783a26
pam_cgfs: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
95ea3d1fa0
network: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
244f7f8734
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>
2019-02-06 11:47:57 +01:00
Christian Brauner
54b43e8f09
monitor: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
f5849fd76f
lxccontainer: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
f01d035800
confile: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
2f443e88ca
conf: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:57 +01:00
Christian Brauner
fdcdb6542b
commands_utils: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:56 +01:00
Christian Brauner
5265a60cba
commands: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:56 +01:00
Christian Brauner
fa4719e2c9
lxc_user_nic: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:56 +01:00
Christian Brauner
861cb8c28a
cgroups: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:56 +01:00
Christian Brauner
57668944d4
lxcmntent: remove stack allocations
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:47:56 +01:00
Christian Brauner
af1dc7cd70
memory_utils: add memory_utils.h
The header defines a simple wrapper for free() that can be used with
gcc's and clang's __attribute__((__cleanup__(<cleanup-fun>))) macro.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 11:44:09 +01:00
Stéphane Graber
0220bddaac
Merge pull request #2824 from brauner/2019-02-05/compiler_based_hardening
compiler: hardening
2019-02-05 18:24:46 -05:00
Christian Brauner
d0afbad9a4
compiler: -Wnested-externs hardening
Warn if an extern declaration is encountered within a function.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-06 00:04:04 +01:00
Christian Brauner
a30c52acb7
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>
2019-02-05 23:49:48 +01:00
Christian Brauner
fcfce08aba
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>
2019-02-05 23:48:32 +01:00
Christian Brauner
463bee7b8d
compiler: -Werror=shift-count-overflow hardening
Warn if shift count >= width of type.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 23:47:31 +01:00
Christian Brauner
3b5a0eebd4
compiler: fix -fstack-protector-strong
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 23:44:20 +01:00
Christian Brauner
64871d419d
compiler: -fdiagnostics-show-option
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 23:26:13 +01:00
Christian Brauner
a703da6c84
compiler: -Werror=overflow hardening
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 23:26:00 +01:00
Christian Brauner
4ccb887813
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>
2019-02-05 23:15:05 +01:00
Stéphane Graber
4e950c76ed
Merge pull request #2823 from brauner/2019-02-05/compiler_based_hardening
compiler: hardening
2019-02-05 16:55:36 -05:00
Christian Brauner
a7547c5c34
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>
2019-02-05 22:36:31 +01:00
Christian Brauner
5573349673
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>
2019-02-05 22:36:31 +01:00
Christian Brauner
d07545c7da
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>
2019-02-05 22:36:31 +01:00
Christian Brauner
42a2ab35f4
compiler: -Werror=incompatible-pointer-types
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 22:36:31 +01:00