Commit Graph

9063 Commits

Author SHA1 Message Date
Matthias Hardt
ebbca85297
commands_utils: fix socket leak when adding state client
If lxc_add_state_client() is called with the container already being in the desired state the client fd will never be closed and is leaking. This is due to setting stay_connected in lxc_cmd for LXC_CMD_ADD_STATE_CLIENT. If the desired state isn't already achieved the client fd will later be closed by calling lxc_cmd_fd_cleanup() but in the other case the client configuration isn't added to the handlers
state clients. So the client fd has to be closed explicitely.

This is simply tested by starting container A and calling lxc-wait -n A -s RUNNING.

Signed-off-by: Matthias Hardt <matthias.hardt@gmail.com>
2020-03-09 19:58:22 +01:00
Matthias Hardt
2b3b8f65e3
Revert "commands_utils: fix socket leak in when adding state client"
This reverts commit d7aa555244.

Signed-off-by: Matthias Hardt <matthias.hardt@gmail.com>
2020-03-09 19:42:55 +01:00
Matthias Hardt
ee38ab3fe2
Revert "commands_utils: indicate taking ownership of state_client_fd in"
This reverts commit cd0dc360ce.

Signed-off-by: Matthias Hardt <matthias.hardt@gmail.com>
2020-03-09 19:42:53 +01:00
Matthias Hardt
cd0dc360ce
commands_utils: indicate taking ownership of state_client_fd in
lxc_add_state_client()

Signed-off-by: Matthias Hardt <matthias.hardt@gmail.com>
2020-03-09 16:12:28 +01:00
Matthias Hardt
d7aa555244
commands_utils: fix socket leak in when adding state client
If lxc_add_state_client() is called with the container already being in
the desired state the client fd will never be closed and is leaking.
This due to setting stay_connected in lxc_cmd for
LXC_CMD_ADD_STATE_CLIENT. If the desired state isn't already achieved
the client fd will later be closed by calling lxc_cmd_fd_cleanup() but
in the other case the client configuration isn't added to the handlers
state clients. So the client fd has to be closed explicitely.

This is simply tested by starting container A and calling lxc-wait -n A
-s RUNNING.

Signed-off-by: Matthias Hardt <matthias.hardt@gmail.com>
2020-03-09 15:56:36 +01:00
Christian Brauner
2fb94e95e6
af_unix: cleanup
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-09 14:24:11 +01:00
Christian Brauner
d31059efa6
Merge pull request #3278 from tomponline/tp-proxy-sleep
network: Adds short sleep between veth setup and neighbour proxy add
2020-03-08 20:43:09 +01:00
Christian Brauner
e901a7a15c
Merge pull request #3277 from tomponline/tp-router-netlink
network: Uses netlink for IP neighbour proxy management
2020-03-08 20:31:43 +01:00
Thomas Parrott
954e36b490 network: Adds short sleep between veth setup and neighbour proxy add
There is an intermittent issue, experienced on at least Ubuntu 18.04 (5.3.0-40-generic) and Alpine 3.11 (5.4.12-1-virt) when using the router network interface type that causes the IP proxy neighbour entries on the host side of the veth pair to not be created.

The `ip neigh add proxy` command returns without an error, however by the time the network up hook has started the IP neighbour proxy entries are no longer there (if they ever were).

I've also tested this using netlink rather than the ip command to add and both are equally affected.

Adding a short sleep between setting up the veth pair and adding the proxy entries appears to fix it.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2020-03-08 18:28:44 +00:00
Thomas Parrott
5fe147e974 network: Uses netlink for IP neighbour proxy management
Removes need for ip command when managing IP neighbour proxies.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2020-03-08 17:58:37 +00:00
Stéphane Graber
1b3e427434
Merge pull request #3275 from brauner/2020-03-05/api_extension
utils: only move_fd() when fdopen() has been successful
2020-03-05 11:36:38 +01:00
Christian Brauner
92bdc5937e
utils: only move_fd() when fdopen() has been successful
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-05 11:14:24 +01:00
Stéphane Graber
4f31df9393
Merge pull request #3274 from brauner/2020-03-05/api_extension
fixes
2020-03-05 10:36:40 +01:00
Christian Brauner
c60ee0a929
api-extensions: document cgroup2_devices and cgroup2 api extensions
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-05 10:12:28 +01:00
Christian Brauner
382854fbd3
Merge pull request #3272 from ffontaine/master
src/lxc/raw_syscalls.c: fix sparc assembly
2020-02-29 03:35:04 +01:00
Fabrice Fontaine
5f7dd076fe src/lxc/raw_syscalls.c: fix sparc assembly
Build of lxc 3.2.1 fails with ultrasparc on:

raw_syscalls.c: In function ‘lxc_raw_clone’:
raw_syscalls.c:66:3: error: invalid 'asm': invalid operand output code
   asm volatile(
   ^~~

Issue has been added with commit
b52e8e68a6 which added %g1 instead of %%g1

Fixes:
 - http://autobuild.buildroot.org/results/17c2319850f02f24da6fbef9656c07f86fdc5a3a

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-02-28 17:45:10 +01:00
Stéphane Graber
67d54d09c2
Merge pull request #3271 from brauner/2020-02-28/support_cgroup_pattern_2
cgroups: honor lxc.cgroup.pattern if set explicitly II
2020-02-28 12:36:30 +01:00
Christian Brauner
d6bdd1823a
cgroups: honor lxc.cgroup.pattern if set explicitly II
Link: https://discuss.linuxcontainers.org/t/lxc-cgroup-pattern-is-not-being-honored
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-02-28 12:16:17 +01:00
Stéphane Graber
2bc4909886
Merge pull request #3270 from brauner/2020-02-27/support_cgroup_pattern
cgroups: honor lxc.cgroup.pattern if set explicitly
2020-02-28 12:08:13 +01:00
Christian Brauner
b3ed206162
cgroups: honor lxc.cgroup.pattern if set explicitly
Link: https://discuss.linuxcontainers.org/t/lxc-cgroup-pattern-is-not-being-honored
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-02-28 11:07:39 +01:00
Stéphane Graber
bf04c8508d
Merge pull request #3268 from brauner/2020-02-25/cgroups
cgroups: remove unused method and cleanup cgroup_exit()
2020-02-25 20:34:18 +01:00
Christian Brauner
c3f5890cfe
cgroups: remove unused method and cleanup cgroup_exit()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-02-25 13:38:32 +01:00
Stéphane Graber
ecf79d49e7
Merge pull request #3265 from brauner/2020-02-13/fix_setgroups
tree-wide: improve setgroups() dropping
2020-02-13 01:10:31 +01:00
Christian Brauner
b58214ac30
tree-wide: improve setgroups() dropping
Drop groups before we change to userns root.

Reported-by: Teddy Reed <teddy.reed@gmail.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-02-13 00:16:15 +01:00
Christian Brauner
1d5f322246
Merge pull request #3264 from tych0/fix-leak
lxclock: fix a small memory leak
2020-02-10 18:06:39 +01:00
Tycho Andersen
b8a6a00cc3 lxclock: fix a small memory leak
if (!name), we allocate an unnamed semaphore, but if we then fail to
allocate/create the lock, we don't free this semaphore, and we just leak
it.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2020-02-10 08:14:33 -07:00
Christian Brauner
a5ee97e629
Merge pull request #3261 from blenk92/fix-parse-config
container.conf: Fix parsing of config options:
2020-02-05 19:49:48 +01:00
Maximilian Blenk
20c3318a80 container.conf: Document that order is important in config_jump_table
Add a comment that documents that more specific options of a
namespace have to be added above more generic options in
config_jump_table.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
2020-02-05 19:31:40 +01:00
Maximilian Blenk
9aee23ad1b container.conf: Fix option ordering in config_jump_table
Currently lxc.selinux.context.keyring is placed after
lxc.selinux.context in config_jump_table. This entails that if
lxc.selinux.context.keyring is specified, lxc.selinux.context will be
matched to that option. This commit places the
lxc.selinux.context.keyring before lxc.selinux.context

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
2020-02-05 19:28:35 +01:00
Maximilian Blenk
52ab03ac19 container.conf: Fix off by 2 in option parsing
This commit fixes a off by 2 in config option parsing
(due to missing parenthesis). The error occurs if for instance
lxc.net.0.type is parsed. In that case, the .0 is removed from the
string. However, due to the missing parenthesis, the null terminating
character is off by two which means the modified config option would
be lxc.net.typepe instead of lxc.net.type.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
2020-02-05 19:18:25 +01:00
Christian Brauner
a8b9febda3
Merge pull request #3260 from blenk92/add-keyring-option
Add keyring option
2020-01-31 15:56:54 +01:00
Maximilian Blenk
ad36e96a3d doc: Add doc for keyring options
Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
2020-01-31 14:33:10 +01:00
Maximilian Blenk
8f818a8454 container.conf: Add option to disable session keyring creation
lxc set's up a new session keyring for every container by default.
There might be valid use-cases where this is not wanted / needed
(e.g. systemd by default creates a new session keyring anyway).

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
2020-01-31 14:33:10 +01:00
Maximilian Blenk
4fef78bc33 container.conf: Add option to set keyring SELinux context
lxc set's up a new session keyring for every container by default.
If executed on an SELinux enabled system, by default, the keyring
inherits the label of the creating process. If executed with the
currently available SELinux policy, this means that the keyring
is labeled with the lxc_t type. Applications inside the container,
however, might expect that the keyring is labeled with a certain
context (and will fail to access the keyring if it's not explicitly
allowed in the global policy). This patch introduces the config
option lxc.selinux.context.keyring which enables to specify the
label of the newly created keyring. That is, the keyring can be
labeled with the label expected by the started application.

Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
2020-01-31 14:33:01 +01:00
Christian Brauner
f5a15e1e3d
Merge pull request #3259 from chobostar/fix_default_cgroup_pattern
cgroups: fix default cgroup pattern
2020-01-27 14:11:12 +01:00
Kirill Petrov
4ba0393577 cgroups: fix default cgroup pattern
Signed-off-by: Kirill Petrov <yakutskkirill@mail.ru>
2020-01-27 11:51:36 +03:00
Stéphane Graber
5f77c7d574
Merge pull request #3255 from brauner/2020-01-16/fix_monitor_hang
start: fix container killing logic
2020-01-17 08:18:10 -05:00
Christian Brauner
11c7d34961
start: fix container killing logic
We need to account for the case where pidfd's are not supported by the kernel
in question.

Closes: #3254
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-16 18:03:39 +01:00
Christian Brauner
917a7c1594
Merge pull request #3253 from tomponline/tp-network-mtu
network: Restore fixed MTU functionality
2020-01-15 11:15:13 +01:00
Thomas Parrott
a00fbab580 network: Restore fixed MTU functionality
If MTU setting is provided in network device config then always use it rather than inheriting from the link device.

Affected both bridge and router veth modes.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2020-01-15 09:57:15 +00:00
Stéphane Graber
e0f8043530
Merge pull request #3251 from brauner/master
test: increase timeout for api reboot tests
2020-01-14 09:58:33 -05:00
Christian Brauner
bd6741f8e9
Merge pull request #3250 from lifeng68/fix_lxc
cgroup.c: fix memory leak at cgroup init failed
2020-01-14 14:11:53 +01:00
Christian Brauner
fb2ac06720
test: increase timeout for api reboot tests
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-14 13:50:45 +01:00
LiFeng
e2a8c0c360 cgroup.c: fix memory leak at cgroup init failed
Signed-off-by: LiFeng <lifeng68@huawei.com>
2020-01-14 04:17:13 -05:00
Stéphane Graber
6f6bd4128e
Merge pull request #3248 from brauner/2020-01-05/veth_devices
network: improve veth device creation
2020-01-10 08:38:28 -05:00
Christian Brauner
8bf64b77ac
network: rework network device creation
This makes all the codepaths easier to follow and also moves and renames
devices in one single step.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-10 12:36:47 +01:00
Christian Brauner
0104c121a7
network: fix network device removal
We can't delete by netdev->ifindex since that's the ifindex of the device in
the container, not on the host. The correct thing is done below.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-09 18:08:48 +01:00
Christian Brauner
3919322d52
tests: log api reboot test failures
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-09 17:10:14 +01:00
Christian Brauner
0858c829b4
network: fix typ and formatting in comment
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-09 16:54:50 +01:00
Christian Brauner
542563017d
network: improve veth device creation
This allows us to avoid having to move the network device. It also allows us to
work around a kernel bug that in combination with a recent change in systemd
244 causes uses of systemd-networkd to not get an ip address.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-01-09 16:54:48 +01:00