Commit Graph

9144 Commits

Author SHA1 Message Date
KATOH Yasufumi
27f451e283 doc: Add lxc.cgroup.dir.{monitor,container,container.inner} to Japanese man
Update for commit a900cba

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2020-04-05 21:18:59 +09:00
Stéphane Graber
8b10fddec4
Merge pull request #3355 from brauner/2020-04-04/fixes
api-extensions: add and document cgroup_advanced_isolation
2020-04-04 10:38:01 -04:00
Christian Brauner
e9619d75b1
api-extensions: add and document cgroup_advanced_isolation
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-04 12:09:21 +02:00
Christian Brauner
a6e5687378
Merge pull request #3353 from Blub/lxc.cgroup.dir-components
introduce lxc.cgroup.dir.{monitor,container,container.inner}
2020-04-03 20:26:02 +02:00
Christian Brauner
e93197e7ec
confile: coding style fixes for set_config_cgroup_container_inner_dir()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-03 20:10:58 +02:00
Christian Brauner
51b07b7036
doc: s/lxc.cgroup.container.namespace/lxc.cgroup.container.inner/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-03 20:08:41 +02:00
Christian Brauner
31691d1bd4
cgroups: remove unused variable
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-03 20:07:41 +02:00
Wolfgang Bumiller
a900cbaf25 introduce lxc.cgroup.dir.{monitor,container,container.inner}
This is a new approach to #1302 with a container-side
configuration instead of a global boolean flag.

Contrary to the previous PR using an optional additional
parameter for the get-cgroup command, this introduces two
new additional commands to get the limiting cgroup path and
cgroup2 file descriptor. If the limiting option is not in
use, these behave identical to their full-path counterparts.

If these variables are used the payload will end up in the
concatenation of lxc.cgroup.dir.container and
lxc.cgroup.dir.container.inner (which may be empty), and the
monitor will end up in lxc.cgruop.dir.monitor. The
directories are fixed, no retry count logic is applied,
failing to create these directories will simply be a hard
error.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-03 17:22:04 +02:00
Christian Brauner
514b0270ce
Merge pull request #3352 from Blub/readd-cgroup-ops-check
Revert "start: remove unnecessary check for valid cgroup_ops"
2020-04-03 10:28:37 +02:00
Wolfgang Bumiller
e2aed383de Revert "start: remove unnecessary check for valid cgroup_ops"
This reverts commit 52520e4f79.

This can be NULL when there's a pre-start hook which fails.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-03 10:22:27 +02:00
Stéphane Graber
2235ad66df
Merge pull request #3350 from brauner/2020-04-02/fixes
lxccontainer: poll takes millisecond not seconds
2020-04-02 12:21:34 -04:00
Christian Brauner
908c75d24f
lxccontainer: poll takes millisecond not seconds
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-02 18:19:31 +02:00
Christian Brauner
2862e55ea3
Merge pull request #3349 from cyphar/cgfsng-uninitialised-2
cgroups: fix build warning on GCC 7
2020-04-02 17:37:17 +02:00
Aleksa Sarai
fdb0b8ab2d
cgroups: fix build warning on GCC 7
GCC 7 appears to be clever enough to detect that transient_len is
uninitialised but not that it won't be used despite [1]. Just initialise
it to zero to stop the complaining, and allow LXC to build on openSUSE
Leap.

[1]: 346830421a ("cgroups: fix "uninitialized transient_len" warning")

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-04-03 02:13:11 +11:00
Stéphane Graber
9f6302e388
Merge pull request #3348 from brauner/2020-04-02/fixes
fixes
2020-04-02 10:35:43 -04:00
Christian Brauner
2ed0ea489a
utils: use setres{u,g}id() in lxc_switch_uid_gid()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-02 11:51:13 +02:00
Christian Brauner
c353b0b950
utils: rework fix_stdio_permissions()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-02 11:50:27 +02:00
Christian Brauner
85ec52bd9f
Merge pull request #3344 from gaohuatao-1/master
fix non-root user cannot write /dev/stdout
2020-04-02 11:38:48 +02:00
Christian Brauner
370a2284be
Merge pull request #3347 from cyphar/cgfsng-uninitialised
cgroups: fix "uninitialized transient_len" warning
2020-04-02 10:46:45 +02:00
Aleksa Sarai
346830421a
cgroups: fix "uninitialized transient_len" warning
Without this change, a build error is triggered if you compile with
-Werror=maybe-uninitialized.

 cgroups/cgfsng.c: In function 'cgfsng_monitor_enter':
 groups/cgfsng.c:1387:9: error: 'transient_len' may be used uninitialized in this function
    ret = lxc_writeat(h->cgfd_mon, "cgroup.procs", transient, transient_len);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The issue is that if handler->transient_pid is 0, then transient_len is
uninitialised but lxc_writeat(..., transient_len) still gets called.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-04-02 19:18:41 +11:00
Christian Brauner
5f2ed0c09f
Merge pull request #3346 from stgraber/master
systemd: Add Documentation key
2020-04-01 23:03:09 +02:00
Stéphane Graber
955ec68d76
Merge pull request #3345 from brauner/2020-03-30/fixes
fixes
2020-04-01 16:57:25 -04:00
Stéphane Graber
9409ea35a0
systemd: Add Documentation key
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2020-04-01 16:57:15 -04:00
Christian Brauner
f553c21746
autotools: don't install run-coccinelle.sh
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-04-01 22:25:53 +02:00
Christian Brauner
632dd634f9
Merge pull request #3343 from Blub/apparmor-mount-rule-generation
apparmor: generate ro,bind,remount rule list
2020-04-01 21:16:34 +02:00
Wolfgang Bumiller
8fddf007b9 apparmor: generate ro,bind,remount rule list
and update to changes based on lxd

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-04-01 19:21:52 +02:00
gaohuatao
6aff515722 fix non-root user cannot write /dev/stdout
Signed-off-by: gaohuatao <gaohuatao@huawei.com>
2020-04-01 09:36:44 -04:00
Christian Brauner
f66fdf2338
Merge pull request #3341 from Blub/upstream-exec-reload
init: add ExecReload to lxc.service to only reload profiles
2020-03-31 20:23:38 +02:00
Christian Brauner
f7d85e98c2
Merge pull request #3342 from Blub/upstream-monitord-service
allow running lxc-monitord as a system daemon
2020-03-31 20:22:48 +02:00
Wolfgang Bumiller
b62782546c allow running lxc-monitord as a system daemon
lxc-monitord instances are spawned on demand and, if this
happens from a service, the daemon is considered part of
it by systemd, as it is running in the same cgroups. This
can be avoided by leaving it running permanently.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-31 15:34:56 +02:00
Wolfgang Bumiller
253f36f9bc init: add ExecReload to lxc.service to only reload profiles
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-31 15:31:23 +02:00
Christian Brauner
52520e4f79
start: remove unnecessary check for valid cgroup_ops
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-31 13:52:59 +02:00
Stéphane Graber
c51c757042
Merge pull request #3340 from brauner/2020-03-30/fixes
cgroups: handle older kernels (e.g. v4.9)
2020-03-30 14:12:59 -04:00
Christian Brauner
7d84916388
cgroups: send two fds to attach to unified cgroup
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-30 19:16:52 +02:00
Christian Brauner
49df620bc2
cgroups: send two attach fds
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-30 18:42:59 +02:00
Christian Brauner
b1ee458e9b
start: log error when failing to create cgroup
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-30 18:17:53 +02:00
Christian Brauner
d1783ef4d0
cgroups: handle older kernels (e.g. v4.9)
On olders kernels the restrictions to move processes between cgroups are
different than they are on newer kernels. Specifically, we're running into the
following check:

if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) &&
    !uid_eq(cred->euid, tcred->uid) &&
    !uid_eq(cred->euid, tcred->suid))
        ret = -EACCES;

which dictates that in order to move a process into a cgroup one either needs
to be global root (no restrictions apply) or the effective uid of the process
trying to move the process and the {saved}uid of the process that is supposed
to be moved need to be identical. The new attaching logic we did didn't
fulfill this criterion for because it's not present on new kernels.

Closes https://github.com/lxc/lxd/issues/7104.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-30 18:17:41 +02:00
Christian Brauner
4446e0fa7c
Merge pull request #3339 from Blub/cmd-get-cgroup-string-termination
verify cgroup controller name
2020-03-30 16:40:36 +02:00
Wolfgang Bumiller
e6bc68d691 verify cgroup controller name
validate that a cgroup controller name is a valid
zero-terminated string before passing it to
`cgroup_ops->get_cgroup()`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-30 16:03:17 +02:00
Stéphane Graber
6821739c3c
Merge pull request #3338 from brauner/2020-03-28/fixes
tree-wide: fixes
2020-03-28 10:54:25 -04:00
Christian Brauner
8408a9cc8d
tree-wide: s/recursive_destroy/lxc_rm_rf/g
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-28 15:06:55 +01:00
Christian Brauner
de6fe1328c
cgroups: better helper naming
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-28 15:06:55 +01:00
Christian Brauner
c468e4d429
cgroups: move check for valid monitor process up
Cc: cenxianlong <cenxianlong@huawei.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-28 15:06:44 +01:00
Christian Brauner
24e84b34e0
Merge pull request #3337 from bale-cen/master
monitor process exited by signal SIGKILL, clean cgroup resource by th…
2020-03-28 10:56:49 +01:00
Stéphane Graber
c396f8e654
Merge pull request #3336 from brauner/2020-03-28/fixes
cgroups: please compilers
2020-03-27 21:48:18 -04:00
cenxianlong
8fcb908d9f monitor process exited by signal SIGKILL, clean cgroup resource by third party
Writing the value 0 to a cgroup.procs file causes the
writing process to be moved to the corresponding cgroup

Signed-off-by: cenxianlong <cenxianlong@huawei.com>
2020-03-28 03:16:27 +02:00
Christian Brauner
5045306b33
cgroups: please compilers
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-28 00:27:00 +01:00
Stéphane Graber
3021b574a0
Merge pull request #3335 from brauner/2020-03-27/fixes
cgroups: use hidden directory for attaching cgroup
2020-03-27 17:33:59 -04:00
Christian Brauner
275e8ef8aa
cgroups: use hidden directory for attaching cgroup
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 22:22:05 +01:00
Stéphane Graber
334c3bfea5
Merge pull request #3333 from brauner/2020-03-27/fixes
conf: simplify userns_exec_minimal()
2020-03-27 17:01:17 -04:00