Commit Graph

7700 Commits

Author SHA1 Message Date
Christian Brauner
8cd059dfdc
Merge pull request #2350 from Blub/seccomp-cleanup-fixup
seccomp: leak fixup
2018-05-25 09:13:29 +02:00
Wolfgang Bumiller
97a9b25848 seccomp: leak fixup
Fix an error case not free()ing the line forgotten during
the move from fgets() on a static buffer to using getline.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: ccf8d128e4 ("seccomp: parse_config_v1()")
2018-05-25 08:58:30 +02:00
Stéphane Graber
1269738063
Merge pull request #2349 from brauner/2018-05-24/prevent_fd_leak
lxccontainer: fix fd leaks when sending signals
2018-05-24 20:22:28 -04:00
Christian Brauner
c0b48eff17
start: log setns() failure
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 00:25:16 +02:00
Christian Brauner
8f3e3c131b
confile: order architectures
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 00:12:46 +02:00
Christian Brauner
9dd541531f
lxccontainer: fix fd leaks when sending signals
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 00:00:50 +02:00
Stéphane Graber
b3365b9346
Merge pull request #2347 from brauner/2018-05-24/seccomp_cleanups
seccomp: cleanup
2018-05-24 16:57:13 -04:00
Stéphane Graber
a055735adb
Merge pull request #2348 from brauner/2018-05-24/pthread_sigmask
tree-wide: s/sigprocmask/pthread_sigmask()/g
2018-05-24 16:53:19 -04:00
Christian Brauner
eabf1ea9cd
utils: fix task_blocking_signal()
sscanf() skips whitespace anyway so don't account for tabs in case the file
layout changes.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:34:20 +02:00
Christian Brauner
b467714b33
tree-wide: s/sigprocmask/pthread_sigmask()/g
The behavior of sigprocmask() is unspecified in multi-threaded programs. Let's
use pthread_sigmask() instead.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 21:01:39 +02:00
Christian Brauner
47f6d547b2
seccomp: lxc_read_seccomp_config()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 19:50:35 +02:00
Christian Brauner
6ca8172db2
seccomp: parse_config()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 19:50:35 +02:00
Christian Brauner
9c3798eba4
seccomp: parse_config_v2()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 17:45:56 +02:00
Christian Brauner
ad9a5b72a9
seccomp: do_resolve_add_rule()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 17:45:56 +02:00
Christian Brauner
04263914e5
seccomp: scmp_filter_ctx get_new_ctx()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 17:45:56 +02:00
Christian Brauner
0197fe2e5e
seccomp: get_hostarch()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 17:45:56 +02:00
Christian Brauner
0b5c590dcc
seccomp: move #ifdefines
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 17:45:56 +02:00
Christian Brauner
f67c94d00a
seccomp: parse_v2_rules()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 17:45:56 +02:00
Christian Brauner
63a49b03f4
seccomp: fix get_seccomp_arg_value()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 16:30:41 +02:00
Christian Brauner
1ab6b4a12e
seccomp: get_v2_action()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 13:47:59 +02:00
Christian Brauner
f0fd80ae3d
seccomp: get_action_name()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 13:46:06 +02:00
Christian Brauner
30448a13ab
seccomp: get_v2_default_action()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 13:42:47 +02:00
Christian Brauner
7ad3767052
utils: add remove_trailing_newlines()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 13:38:08 +02:00
Christian Brauner
ccf8d128e4
seccomp: parse_config_v1()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 13:35:01 +02:00
Christian Brauner
5fdc4e77a6
lxcseccomp: cleanup header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 13:34:49 +02:00
Christian Brauner
73b5b70eb7
Merge pull request #2345 from flx42/seccomp-fixes
Seccomp fixes
2018-05-24 11:30:30 +02:00
Felix Abecassis
eacebcc3cb seccomp: fix type mismatch when parsing syscall arguments filters
Specifier %lli was insufficient for the type uint64_t, all values
between 2^63-1 and 2^64-1 were silently converted to 2^63-1.

We can't use %llu since it doesn't handle hexadecimal. Instead, we
parse the values as strings and then use strtoull(3).

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-05-23 22:38:25 -07:00
Felix Abecassis
30adf868bf seccomp: remove unnecessary memset
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-05-23 21:32:26 -07:00
Felix Abecassis
9c7423ce2f seccomp: remove confusing comment line
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-05-23 21:28:01 -07:00
Felix Abecassis
3a2cd4b958 seccomp: fix off-by-one error in array allocation for sscanf
The maximum field width does not include the null terminator.

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-05-23 20:54:32 -07:00
Stéphane Graber
f217dcd039
Merge pull request #2344 from brauner/2018-05-23/on_demand_log_file
tools: only create log file when requested
2018-05-23 11:28:01 -04:00
Stéphane Graber
f6c94d9a4c
Merge pull request #2340 from brauner/2018-05-22/fix_init_cmd
lxc-init: skip signals that can't be caught
2018-05-23 11:27:10 -04:00
Stéphane Graber
cd7cf94be7
Merge pull request #2338 from brauner/2018-05-17/multi_threaded_logging
log: enable per-thread container name prefix
2018-05-23 11:26:43 -04:00
Christian Brauner
f6d79ec119
tools: only create log file when requested
We used to initialize a log unconditionally before. This has led to scenarios
where users where left with container directories and an empty log file even
though they didn't request a log be created at all.
Switch all tools to only create a log file when the user explicitly requests
this.

Closes #1779.
Closes #2032.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-23 13:49:42 +02:00
Christian Brauner
12ad9ba7a8
Merge pull request #2341 from tych0/optionally-execveat
use execveat syscall to exec lxc-init if supported
2018-05-23 12:25:42 +02:00
Tycho Andersen
4b5b3a2a29
execute: use execveat() syscall if supported
The execveat allows us to exec stuff via a fd so we don't have to bind mount
stuff in. See the comment about why we're using the syscall directly.

Closes #2339.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
[christian.brauner@ubuntu.com: adapt error message and whitespace fixes]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-23 12:05:10 +02:00
Christian Brauner
11c69d5e77
lxc-init: skip signals that can't be caught
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-22 23:26:03 +02:00
Serge Hallyn
394769b16a
Merge pull request #2337 from brauner/2018-05-18/cgroup_rework
cgroups: refactor cgroup handling
2018-05-22 14:48:39 -05:00
Christian Brauner
c7b1705112
log: enable per-thread container name prefix
When using the LXC API multi-thread and users initialize a log:

struct lxc_log log;
log.name = "my-log";
lxc_log_init(&log);

all threads will have the same "my-log" prefix even though thy might call
lxc_container_new() in separate threads. There is currently no easy way to
handle per-thread container name prefixes.
To handle this carry a reference to the name of the container in struct
lxc_conf and if no log.name was set, use it by default. This way each thread
will get the container it is currently working on as a log-prefix.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reported-by: duguhaotian <duguhaotian@gmail.com>
2018-05-20 14:05:51 +02:00
Christian Brauner
395b1a3ed6
conf: simplify write_id_mapping()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:51:29 +02:00
Christian Brauner
b1c428f9e8
seccomp: #ifdef SCMP_ARCH_AARCH64
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:33:34 +02:00
Christian Brauner
dd66700c56
cgroups: remove freezer_state()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:33:34 +02:00
Christian Brauner
2202afc960
cgroups: refactor cgroup handling
This replaces the constructor implementation of cgroup handling with a simpler,
thread-safe on-demand model of cgroup driver initialization.
Making the cgroup initialization code run in a constructor means that each time
the shared library gets mapped the cgroup parsing code gets run. That's
unnecessary overhead.
It also feels to me that this is only accidently thread-safe because
constructors are only run once. But should threads actually end up manipulating
or freeing memory that is file-global to cgfsng.c we'd be screwed. Now, I might
be wrong here but the cleaner implementation is to allocate a cgroup driver on
demand whenever we need it.
Take the chance and rework the cgroup_ops interface to make the functions it
wants to have implemented a lot cleaner.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-19 22:33:34 +02:00
Christian Brauner
f49098e0d3
Merge pull request #2328 from simos/fix-resource-leak-cid1425802
coverity: #1425802
2018-05-17 13:11:39 +02:00
Simos Xenitellis
1e7cd2f795
coverity: #1425802
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-17 12:43:45 +02:00
Christian Brauner
b5ead53aaf
Merge pull request #2324 from simos/fix-resource-leak-cid1248106
Fixed resource leak in is_wlan() at network.c
2018-05-16 18:31:10 +02:00
Christian Brauner
6ef5e0cf9f
Merge pull request #2323 from simos/fix-resource-leak-cid1425836
Fixed resource leak in userns_exec_full()
2018-05-16 18:15:29 +02:00
Serge Hallyn
23cf184dae
Merge pull request #2332 from brauner/2018-05-16/use_ambient_capabilities
capabilities: raise ambient capabilities
2018-05-16 09:46:54 -05:00
Christian Brauner
611ddd345e
capabilities: raise ambient capabilities
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Suggested-by: Jonathan Calmels <jcalmels@nvidia.com>
2018-05-16 15:56:57 +02:00
Stéphane Graber
02d6227d1e
Merge pull request #2319 from brauner/2018-05-13/allow_sys_rw_for_unpriv_containers
config: allow read-write /sys in user namespace
2018-05-15 10:34:22 -04:00