Commit Graph

9423 Commits

Author SHA1 Message Date
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
Christian Brauner
dbfcdf8600
conf: simplify userns_exec_minimal()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 21:48:46 +01:00
Stéphane Graber
64e4f71582
Merge pull request #3332 from brauner/2020-03-27/fixes
attach: fixes
2020-03-27 15:37:00 -04:00
Christian Brauner
edf8828912
conf: introduce and use userns_exec_minimal()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 20:11:41 +01:00
Christian Brauner
4b86fefd0f
Revert "cgroups: fix unified cgroup attach"
This reverts commit ba7ca43b0b.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 19:46:10 +01:00
Stéphane Graber
c0c183b345
Merge pull request #3331 from brauner/2020-03-27/fixes
tree-wide: fixes
2020-03-27 11:02:27 -04:00
Wolfgang Bumiller
f7a97743a3
fixup i/o handler return values
Particularly important for lxc_cmd_handler() handles client
input and should not be capable of canceling the main loop,
some syscall return values leaked through overlapping with
LXC_MAINLOOP_ERROR, causing unauthorized clients connecting
to the command socket to shutdown the main loop.

In turn, signal_handler() receiving unexpected
`signalfd_siginfo` struct sizes seems like a reason to bail
(since it's a kernel interface).

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 15:45:11 +01:00
Christian Brauner
ba7ca43b0b
cgroups: fix unified cgroup attach
There's a fundamental problem with futexes and setid calls and the go runtime.
POSIX requires that when one thread setids all threas must setids and it uses
futexes and signals to synchronize the state across threads. This causes
deadlocks which means we can't use the pretty solution I first implemented.
Instead we need to chown after we create the directory. I might come up with
something smarter later but for now this will do.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 15:45:11 +01:00
Stéphane Graber
d4a5002bb7
Merge pull request #3330 from brauner/2020-03-27/fixes
conf: rework and fix leak in userns_exec_1()
2020-03-27 08:52:30 -04:00
Christian Brauner
0d113b16f0
cgroups: remove unused variable
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 12:00:22 +01:00
Christian Brauner
8bc2b675f2
attach: use close_prot_errno_disarm()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 11:52:44 +01:00
Christian Brauner
32908bfd12
cgroups: rework __cg_unified_attach()
We didn't account for cgroup_attach() succeeding and just tried to attach to
the same cgroup again which doesn't make sense.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 11:47:49 +01:00
Christian Brauner
7c2c435c52
cgroups: move pointer dereference after check
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 11:47:49 +01:00
Christian Brauner
a5263e59fd
commands: log actual errno when lxc_cmd_get_cgroup2_fd() fails
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 11:47:48 +01:00
Christian Brauner
766c5b6d75
conf: rework and fix leak in userns_exec_1()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-27 11:47:48 +01:00
Stéphane Graber
8c6a7ee44c
Merge pull request #3329 from brauner/2020-03-25/fixes
cgroups: fix attaching to the unified cgroup
2020-03-26 15:11:50 -04:00
Christian Brauner
7581a82fde
cgroups: fix attaching to the unified cgroup
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-26 19:27:07 +01:00
Stéphane Graber
45d6d89ba4
Merge pull request #3328 from brauner/2020-03-25/fixes
tree-wide: fixes
2020-03-26 11:22:34 -04:00
Christian Brauner
65146c9729
dir: improve dir backend
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-26 15:47:11 +01:00
Christian Brauner
0f2e356612
dir: use cleanup macro in dir_mount()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-26 15:32:29 +01:00
Christian Brauner
a08bfbe340
tree-wide: harden mount option parsing
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2020-03-26 15:31:57 +01:00
Stéphane Graber
75688909d2
Merge pull request #3327 from P-EB/master
lxc.service: Starts after remote-fs.target
2020-03-25 13:31:45 -04:00