Commit Graph

8146 Commits

Author SHA1 Message Date
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
Christian Brauner
13311d70fe
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>
2019-02-05 22:36:31 +01:00
Christian Brauner
e3b4674d44
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>
2019-02-05 22:36:30 +01:00
Christian Brauner
30462b9144
compiler: -Wfloat-equal hardening
Warn if floating-point values are used in equality comparisons.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 22:36:30 +01:00
Christian Brauner
f03f7b5ce5
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>
2019-02-05 22:36:30 +01:00
Christian Brauner
11af5f2ba1
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>
2019-02-05 22:36:30 +01:00
Christian Brauner
cc0c3a0612
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>
2019-02-05 22:36:30 +01:00
Christian Brauner
fb3b3ef484
compiler: -Wlogical-op hardening
Warn about suspicious uses of logical operators in expressions.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-05 22:36:30 +01:00
Stéphane Graber
1fba6a8589
Merge pull request #2822 from tomponline/tp-rpmspec
fix rpm packaging for bash completion directory.
2019-02-05 18:16:41 +01:00
tomponline
a8a6c2c659 fix rpm packaging for bash completion directory.
Closed #1825

Signed-off-by: tomponline <tomp@tomp.uk>
2019-02-05 17:10:20 +00:00
Stéphane Graber
9fb7aab8a8
Merge pull request #2820 from brauner/2019-01-31/cgfsng_sys/kernel/cgroup/delegate
cgroups: use of /sys/kernel/cgroup/delegate file
2019-02-01 12:38:14 +01:00
Stéphane Graber
59c66b4800
Merge pull request #2787 from Blub/2019-01-17/revert-sys-double-bindmount-cleanup
Revert "conf: remove extra MS_BIND with sysfs:mixed"
2019-02-01 12:37:38 +01:00
Christian Brauner
a6ca2ed891
cgroups: use of /sys/kernel/cgroup/delegate file
This file contains the files one needs to chown to successfully delegate
cgroup files to unprivileged users.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-02-01 11:31:46 +01:00
Christian Brauner
5b353da900
Merge pull request #2806 from brauner/2019-01-27/bugfixes
freezer: non-functional changes
2019-01-31 11:38:04 +01:00
Christian Brauner
02f71d7ef0
freezer: non-functional changes
Fix the coding style in a few files.

Fixes: db1228b35f ("Avoid hardcoded string length")
Fixes: 71fc9c0468 ("Avoid risk of "too far memory read"")
Fixes: 2341916a03 ("Avoid double lxc-freeze/unfreeze")
Fixes: 9eb9ce3e47 ("Update freezer.c")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-31 11:34:46 +01:00
Christian Brauner
9fc6fd2107
Merge pull request #2817 from Rachid-Koucha/patch-5
More accurate error msg for template file
2019-01-29 13:06:22 +01:00
Rachid Koucha
b275efe319
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>
2019-01-29 12:20:46 +01:00
Stéphane Graber
dea31fe2c5
Merge pull request #2807 from brauner/2019-01-27/mount_entries
conf: check for successful mount entry parse
2019-01-28 17:24:01 -05:00
Christian Brauner
91046ccd42
Merge pull request #2814 from tenforward/japanese
doc: Add lxc.seccomp.allow_nesting to Japanese lxc.container.conf(5)
2019-01-28 11:54:45 +01:00
KATOH Yasufumi
7a8f46e955 doc: Add lxc.seccomp.allow_nesting to Japanese lxc.container.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2019-01-28 19:01:40 +09:00
Serge Hallyn
ca5a24d334
Merge pull request #2813 from brauner/2019-01-27/bugfixes_2
compiler: remove deprecated and unneeded header
2019-01-27 21:41:49 -06:00
Christian Brauner
acad8485a0
prlimit: remove deprecated and unneeded header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 23:05:47 +01:00
Christian Brauner
0f3a3e1a47
compiler: remove deprecated and unneeded header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 23:02:49 +01:00
Christian Brauner
7c9f712dcf
Merge pull request #2812 from Rachid-Koucha/patch-7
/etc/resolv.conf grows indefinitely
2019-01-27 14:03:40 +01:00
Rachid Koucha
567f891596
/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>
2019-01-27 13:46:48 +01:00
Christian Brauner
dc691e340e
conf: append 0 0 to nesting helpers mount entries
Otherwise musl's getmntent_r() parser will fail.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-01-27 13:16:09 +01:00
Christian Brauner
8f2cce180e
Merge pull request #2811 from Rachid-Koucha/patch-6
Create /var/run
2019-01-27 13:07:03 +01:00
Rachid Koucha
c65973ad89
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>
2019-01-27 12:23:58 +01:00