Commit Graph

8686 Commits

Author SHA1 Message Date
Stéphane Graber
76b65b40c2
Merge pull request #3037 from brauner/master
seccomp: align with upstream libseccomp
2019-06-11 17:43:10 -04:00
Christian Brauner
d7d2d2d9a5
seccomp: s/HAVE_DECL_SECCOMP_NOTIF_GET_FD/HAVE_DECL_SECCOMP_NOTIFY_FD/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:36:56 +02:00
Christian Brauner
9965620643
seccomp: /sseccomp_notif_free/seccomp_notify_free/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:34:33 +02:00
Christian Brauner
1f51fc702b
seccomp: s/seccomp_notif_alloc/seccomp_notify_alloc/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:33:22 +02:00
Christian Brauner
72b101aedf
seccomp: s/seccomp_notif_id_valid/seccomp_notify_id_valid/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:32:19 +02:00
Christian Brauner
3c216fe27b
seccomp: s/seccomp_notif_send_resp/seccomp_notify_respond/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:31:12 +02:00
Christian Brauner
e3998402d6
seccomp: s/seccomp_notif_receive/seccomp_notify_receive/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:29:39 +02:00
Christian Brauner
da9c8317e8
seccomp: s/seccomp_notif_get_fd/seccomp_notify_fd/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:27:33 +02:00
Christian Brauner
02ca9d758e
seccomp: s/SCMP_ACT_USER_NOTIF/SCMP_ACT_NOTIFY/g
Align with upstream libseccomp.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-11 23:25:44 +02:00
Christian Brauner
e9ab177d3f
Merge pull request #3032 from promlow/lxcbasename_fix
proposed fix for #2892 - fix lxcbasename in lxc/lxccontainer.c
2019-06-07 02:35:39 +02:00
Stéphane Graber
20a64b0b0d
Merge pull request #3034 from brauner/2019-06-05/boot_id
start: generate new boot id on container start
2019-06-06 12:57:11 +02:00
Christian Brauner
2050265234
start: generate new boot id on container start
Closes #3027.

BugLink: https://bugs.launchpad.net/bugs/1831258
Cc: Dimitri John Ledkov <xnox@ubuntu.com>
Cc: Scott Moser <smoser@ubuntu.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-06 01:20:37 +02:00
Paul Romlow
85e02f5600 proposed fix for #2892 - fix lxcbasename in lxc/lxccontainer.c
Signed-off-by: Paul Romlow <paul@romlow.com>
2019-06-05 13:28:21 -05:00
Stéphane Graber
1d51e3de49
Merge pull request #3029 from brauner/2019-06-05/fix_offline_cpus
cgroups: prevent segfault
2019-06-05 13:09:42 +02:00
Christian Brauner
8e75ed57cc
Merge pull request #3031 from Rachid-Koucha/patch-11
Make /tmp accessible to any user
2019-06-05 13:08:39 +02:00
Rachid Koucha
a725bbc4b7
Make /tmp accessible to any user
/tmp created with "rwxrwxrwt" mode

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-06-05 13:04:11 +02:00
Christian Brauner
dcd14a3db6
cgroups: prevent segfault
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-06-05 09:31:17 +02:00
Christian Brauner
fa0330c9c0
Merge pull request #3028 from lifeng68/fix_memory_leak
start: fix handler memory leak at lxc_init failed
2019-06-05 06:56:17 +02:00
LiFeng
39cb2d9ee8 start: fix handler memory leak at lxc_init failed
Signed-off-by: LiFeng <lifeng68@huawei.com>
2019-06-05 00:44:17 -04:00
Christian Brauner
c86d12141a
Merge pull request #3026 from xmcqueen/master
lxc_usernsexec: continuing after unshare fails leads to confusing and…
2019-06-04 16:11:42 +02:00
Brian McQueen
dfe4a687a2 lxc_usernsexec: continuing after unshare fails leads to confusing and misleading error messages
Signed-off-by: Brian McQueen <bmcqueen@linkedin.com>
2019-06-04 06:46:37 -07:00
Stéphane Graber
94d3c14dd7
Merge pull request #3014 from brauner/2019-05-24/cgroups_handle_offline_cpus
cgroups: handle offline cpus in v1 hierarchy
2019-06-04 13:52:07 +02:00
Christian Brauner
1eaa8c428a
Merge pull request #3024 from avkvl/fix_groups_with_a_lot_of_members
lxc-user-net: Failed to convert string " Failed to get group name" to integer
2019-06-04 10:49:57 +02:00
Alexander Kriventsov
b9f80409d7 getgrgid_r fails with ERANGE if buffer is too small. Retry with a larger buffer.
Signed-off-by: Alexander Kriventsov <akriventsov@nic.ru>
2019-06-03 18:11:56 +03:00
Christian Brauner
3e8a11cb1c
Merge pull request #3018 from tych0/comment-stack-size
lxc_clone: add a comment about stack size
2019-05-29 17:38:23 +02:00
Tycho Andersen
edb808d130 lxc_clone: add a comment about stack size
Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2019-05-29 09:36:51 -06:00
Christian Brauner
18a405ee88
Merge pull request #2987 from tych0/pass-zero-to-clone
Pass zero to clone
2019-05-29 17:14:00 +02:00
Tycho Andersen
3df90604ec lxc_clone: bump stack size to 8MB
This is the default thread size for glibc, so it is reasonable to match
that when we clone().

Mostly this is a science experiment suggested by brauner, and who doesn't
love science?

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2019-05-29 08:47:35 -06:00
Christian Brauner
0cfec4f757
Merge pull request #3015 from avkvl/issue-2765
fix issue 2765
2019-05-28 16:45:36 +02:00
Alexander Kriventsov
d871a9f1e5 fix issue 2765
Signed-off-by: Alexander Kriventsov <akriventsov@nic.ru>
2019-05-28 16:21:22 +03:00
Christian Brauner
36f7018103
cgroups: handle offline cpus in v1 hierarchy
Handle offline cpus in v1 hierarchy.

In addition to isolated cpus we also need to account for offline cpus when our
ancestor cgroup is the root cgroup and we have not been initialized yet.

Closes #2953.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-05-24 15:59:57 +02:00
Stéphane Graber
c54cf53fad
Merge pull request #3011 from brauner/2019-05-21/android_the_bane_of_my_existence
configure: remove additional comma
2019-05-21 10:15:08 -04:00
Christian Brauner
d4df64143e
configure: remove additional comma
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-05-21 15:58:03 +02:00
Stéphane Graber
ddf4b77e11
Merge pull request #3010 from brauner/2019-05-17/bugfixes
lxccontainer: cleanup attach functions
2019-05-17 09:10:47 +02:00
Christian Brauner
d643014317
lxccontainer: cleanup attach functions
Specifically, refloat function arguments and remove useless comments.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-05-17 07:50:45 +02:00
Stéphane Graber
07c5b72a11
Merge pull request #3009 from brauner/2019-05-16/rework_attach
attach: do not reload container
2019-05-16 19:33:41 +02:00
Christian Brauner
908fbc1a2e
attach: do not reload container
Let lxc_attach() reuse the already initialized container.

Closes https://github.com/lxc/lxd/issues/5755.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-05-16 16:11:22 +02:00
Christian Brauner
6ae34d2169
Merge pull request #3006 from tomponline/tp-phys-downhook
network: Fixes bug that stopped down hook from running for phys netdevs
2019-05-16 10:11:42 +02:00
Thomas Parrott
b3259dc669 network: Fixes bug that stopped down hook from running for phys netdevs
Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2019-05-15 17:09:47 +01:00
Christian Brauner
e2f2d86a41
Merge pull request #3005 from tomponline/tp-phys-ns-restore
network: move phys netdevs back to monitor's net ns rather than pid 1's
2019-05-15 17:40:52 +02:00
Thomas Parrott
0037ab49d6 network: move phys netdevs back to monitor's net ns rather than pid 1's
Updates lxc_restore_phys_nics_to_netns() to move phys netdevs back to the monitor's network namespace rather than the previously hardcoded PID 1 net ns.

This is to fix instances where LXC is started inside a net ns different from PID 1 and physical devices are moved back to a different net ns when the container is shutdown than the net ns than where the container was started from.

Signed-off-by: Thomas Parrott <thomas.parrott@canonical.com>
2019-05-15 15:58:46 +01:00
Stéphane Graber
8f06ff5491
Merge pull request #3004 from brauner/master
configure: handle checks when cross-compiling
2019-05-15 16:19:19 +02:00
Tycho Andersen
5e7b4b3c16 lxc_clone: get rid of some indirection
We have a do_clone(), which just calls a void f(void *) that it gets
passed. We build up a struct consisting of two args that are just the
actual arg and actual function. Let's just have the syscall do this for us.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2019-05-15 07:56:29 -06:00
Tycho Andersen
8de9038436 doc: add a little note about shared ns + LSMs
We should add a little not about the race in the previous patch.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2019-05-15 07:56:01 -06:00
Tycho Andersen
c74e921744 lxc_clone: pass non-stack allocated stack to clone
There are two problems with this code:

1. The math is wrong. We allocate a char *foo[__LXC_STACK_SIZE]; which
   means it's really sizeof(char *) * __LXC_STACK_SIZE, instead of just
   __LXC_STACK SIZE.

2. We can't actually allocate it on our stack. When we use CLONE_VM (which
   we do in the shared ns case) that means that the new thread is just
   running one page lower on the stack, but anything that allocates a page
   on the stack may clobber data. This is a pretty short race window since
   we just do the shared ns stuff and then do a clone without CLONE_VM.

However, it does point out an interesting possible privilege escalation if
things aren't configured correctly: do_share_ns() sets up namespaces while
it shares the address space of the task that spawned it; once it enters the
pid ns of the thing it's sharing with, the thing it's sharing with can
ptrace it and write stuff into the host's address space. Since the function
that does the clone() is lxc_spawn(), it has a struct cgroup_ops* on the
stack, which itself has function pointers called later in the function, so
it's possible to allocate shellcode in the address space of the host and
run it fairly easily.

ASLR doesn't mitigate this since we know exactly the stack offsets; however
this patch has the kernel allocate a new stack, which will help. Of course,
the attacker could just check /proc/pid/maps to find the location of the
stack, but they'd still have to guess where to write stuff in.

The thing that does prevent this is the default configuration of apparmor.
Since the apparmor profile is set in the second clone, and apparmor
prevents ptracing things under a different profile, attackers confined by
apparmor can't do this. However, if users are using a custom configuration
with shared namespaces, care must be taken to avoid this race.

Shared namespaces aren't widely used now, so perhaps this isn't a problem,
but with the advent of crio-lxc for k8s, this functionality will be used
more.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2019-05-15 07:56:01 -06:00
Christian Brauner
4e900c18a7
configure: handle checks when cross-compiling
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2019-05-15 15:44:36 +02:00
Christian Brauner
7aea50feb9
Merge pull request #3001 from Rachid-Koucha/patch-11
Use %m instead of strerror() when available
2019-05-13 15:57:29 +02:00
Rachid Koucha
9a719a64e5
Error prone semicolon
Suppressed error prone semicolon in SYSTRACE() macro.

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-05-13 14:57:02 +02:00
Rachid Koucha
a1d652c25b
Use %m instead of strerror() when available
Use %m under HAVE_M_FORMAT instead of strerror()

Signed-off-by: Rachid Koucha <rachid.koucha@gmail.com>
2019-05-13 13:21:14 +02:00
Christian Brauner
612e48a364
Merge pull request #2999 from rikardfalkeborn/fix-realloc-memleak-proctitle
initutils: Fix memleak on realloc failure
2019-05-13 13:19:55 +02:00