Commit Graph

7158 Commits

Author SHA1 Message Date
Christian Brauner
1aa52fc6d2
conf: non-functional changes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-27 00:07:03 +02:00
Christian Brauner
0ace00870b
coverity: #1435747
Dereference before null check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-26 11:44:41 +02:00
Christian Brauner
13fae236f8
coverity: #1435803
Unchecked return value

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-26 11:44:40 +02:00
Christian Brauner
02139e2969
coverity: #1435805
Logically dead code

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-26 11:44:39 +02:00
Christian Brauner
22cfc4fa8a
coverity: #1435806
Logically dead code

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-26 11:44:38 +02:00
Christian Brauner
918d16b79e
tools: fix lxc-create with global config value II
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-26 11:44:33 +02:00
Christian Brauner
5a09d96ef4
tools: fix lxc-create with global config value
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 16:13:38 +02:00
Christian Brauner
460babdb46
seccomp: make do_resolve_add_rule() more strict
Let's error out on syscalls that cannot be resolved or fail to resolve instead
of just warning users.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 16:13:36 +02:00
Christian Brauner
ab0dd94dc7
seccomp: parse_v2_rules()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 16:13:34 +02:00
Christian Brauner
527d15f864
seccomp: lxc_read_seccomp_config()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 16:13:31 +02:00
Wolfgang Bumiller
3b09ea5a71
seccomp: error on unrecognized actions
Be more strict about unrecognized actions. Previously the
parser would happily accept lines with typos like:

  kexec_load errrno 1

(note the extra 'r')

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2018-05-25 12:46:52 +02:00
Wolfgang Bumiller
3ce8c639a3
seccomp: refactor line handling of parse_config
Moving parse_config_v2 to use getline accidentally parsed
the wrong buffer. Since both _v1 and _v2 now use getline it
seems to be simpler to also use getline() for the first line
before entering the version specific parsers and pass along
the pointer and size so they can reuse them.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: 9c3798eba4 ("seccomp: parse_config_v2()")
2018-05-25 12:46:51 +02:00
Wolfgang Bumiller
c88d84cbf5
seccomp: re-add action parse error handling
This can happen when the 'errno' action can't parse its
supplied number.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Fixes: f67c94d00a ("seccomp: parse_v2_rules()")
2018-05-25 12:46:49 +02:00
Wolfgang Bumiller
0d83285d46
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 12:46:48 +02:00
Christian Brauner
6e816a91b9
start: log setns() failure
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 12:46:47 +02:00
Christian Brauner
2c16d4e59d
confile: order architectures
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 12:46:46 +02:00
Christian Brauner
1b4872c760
lxccontainer: fix fd leaks when sending signals
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-25 12:46:43 +02:00
Christian Brauner
42a0468fa6
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 23:00:09 +02:00
Christian Brauner
d6dbd2680f
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 23:00:07 +02:00
Christian Brauner
8f0f76ebbd
seccomp: lxc_read_seccomp_config()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:06 +02:00
Christian Brauner
800f0db55b
seccomp: parse_config()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:05 +02:00
Christian Brauner
cf6201b45f
seccomp: parse_config_v2()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:04 +02:00
Christian Brauner
4a78ed5d7b
seccomp: do_resolve_add_rule()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:03 +02:00
Christian Brauner
9ec37277b5
seccomp: scmp_filter_ctx get_new_ctx()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:03 +02:00
Christian Brauner
cf1bd7e4db
seccomp: get_hostarch()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:02 +02:00
Christian Brauner
f55ef0ba98
seccomp: move #ifdefines
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:01 +02:00
Christian Brauner
4a9da964d2
seccomp: parse_v2_rules()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 23:00:00 +02:00
Christian Brauner
24ee971775
seccomp: fix get_seccomp_arg_value()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:59 +02:00
Christian Brauner
a90344014b
seccomp: get_v2_action()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:59 +02:00
Christian Brauner
46acf530b8
seccomp: get_action_name()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:58 +02:00
Christian Brauner
d153b33da8
seccomp: get_v2_default_action()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:57 +02:00
Christian Brauner
dc840f5d53
utils: add remove_trailing_newlines()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:56 +02:00
Christian Brauner
844e091b14
seccomp: parse_config_v1()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:55 +02:00
Christian Brauner
32d8e67961
lxcseccomp: cleanup header
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:59:51 +02:00
Felix Abecassis
871746f2f2
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-24 22:48:16 +02:00
Felix Abecassis
7cbf948f7d
seccomp: remove unnecessary memset
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-05-24 22:48:13 +02:00
Felix Abecassis
88b95f3899
seccomp: remove confusing comment line
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2018-05-24 22:48:12 +02:00
Felix Abecassis
95cdca6866
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-24 22:48:11 +02:00
Christian Brauner
d347dbaa4b
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-24 22:48:08 +02:00
Tycho Andersen
80370cecf6
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-24 22:48:04 +02:00
Christian Brauner
2a6be93564
lxc-init: skip signals that can't be caught
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:48:02 +02:00
Christian Brauner
56530d78a1
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-24 22:48:00 +02:00
Christian Brauner
48c99954f7
conf: simplify write_id_mapping()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:47:57 +02:00
Christian Brauner
d78980250b
seccomp: #ifdef SCMP_ARCH_AARCH64
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:47:55 +02:00
Christian Brauner
c701a1d791
cgroups: remove freezer_state()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-05-24 22:47:53 +02:00
Christian Brauner
893b660cf6
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-24 22:47:48 +02:00
Simos Xenitellis
e37266ab6f
coverity: #1425802
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-21 13:21:04 +02:00
Christian Brauner
556783f259
capabilities: raise ambient capabilities
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Suggested-by: Jonathan Calmels <jcalmels@nvidia.com>
2018-05-16 21:43:24 +02:00
Simos Xenitellis
b02fb0a7d1
coverity: #1248106
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-16 21:43:23 +02:00
Simos Xenitellis
4ecff63cd1
coverity: #1425836
Resource leak

Signed-off-by: Simos Xenitellis <simos.lists@googlemail.com>
2018-05-16 21:43:19 +02:00