Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Container fails to start with x86_64 Kernel and x86 userland #654

Closed
copyninja opened this issue Sep 12, 2015 · 13 comments
Closed

Container fails to start with x86_64 Kernel and x86 userland #654

copyninja opened this issue Sep 12, 2015 · 13 comments

Comments

@copyninja
Copy link

Hi,
I've bit of weird setup in my laptop. I run Debian unstable with x86_64 kernel but 386 userland. uname command output on my system looks like below
Linux rudra 4.1.0-2-amd64 #1 SMP Debian 4.1.6-1 (2015-08-23) x86_64 GNU/Linux

I've created a container using below configuration

lxc.cgroup.cpuset.cpus = 0,1
lxc.cgroup.cpu.shares = 200

lxc.cgroup.memory.limit_in_bytes = 900M
lxc.cgroup.memory.soft_limit_in_bytes = 512M

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = natbr0
lxc.network.name = eth0

lxc.utsname = sidbuilder.copyninja.info
lxc.arch = x86

Now when I try to start the container with lxc-start I see below error

lxc-start: seccomp.c: get_new_ctx: 167 Seccomp error -17 (Unknown error -17) adding arch: 2
lxc-start: start.c: lxc_init: 382 failed loading seccomp policy
lxc-start: start.c: __lxc_start: 1045 failed to initialize the container
lxc-start: lxc_start.c: main: 342 The container failed to start.
lxc-start: lxc_start.c: main: 346 Additional information can be obtained by setting the --logfile and --logpriority options.

Is it possible to run lxc undex x86_64 kernel with 386 (x86) user land?..

@jirutka
Copy link
Contributor

jirutka commented Sep 12, 2015

Just curious, why you run x86_64 kernel with x86 userland?

@copyninja
Copy link
Author

Better performance, I have a old 64 bit capable laptop which gets strained when running full 64 bit system. So running 64bit kernel with 32 bit userland which has improved memory footprints compared to full 64 bit system (Well haven't benchmarked it though).

@hallyn
Copy link
Member

hallyn commented Sep 15, 2015

Hi,

this seems like it may be a problem in your libseccomp. Exactly what release are you on?

On Ubuntu 15.10, I do:

sudo lxc-create -t download -n t1 -- -d ubuntu -r trusty -a i386
sudo grep -i arch /var/lib/lxc/t1/config
lxc.arch = x86
sudo lxc-start -n t1
sudo lxc-attach -n t1 -- grep -i seccomp /proc/self/status
Seccomp: 2

@copyninja
Copy link
Author

@hallyn Sorry for delayed response on my system ldd shows below output.

vasudev@rudra:~/Documents/Debian/collab-maint/lcdf-typetools$ ldd /usr/bin/lxc-create 
        linux-gate.so.1 (0xf774a000)
        liblxc.so.1 => /usr/lib/i386-linux-gnu/liblxc.so.1 (0xf76b1000)
        libcap.so.2 => /lib/i386-linux-gnu/libcap.so.2 (0xf76ab000)
        libapparmor.so.1 => /lib/i386-linux-gnu/libapparmor.so.1 (0xf7698000)
        libselinux.so.1 => /lib/i386-linux-gnu/libselinux.so.1 (0xf7670000)
        libseccomp.so.2 => /lib/i386-linux-gnu/libseccomp.so.2 (0xf7655000)
        libutil.so.1 => /lib/i386-linux-gnu/i686/cmov/libutil.so.1 (0xf7651000)
        libpthread.so.0 => /lib/i386-linux-gnu/i686/cmov/libpthread.so.0 (0xf7635000)
        libc.so.6 => /lib/i386-linux-gnu/i686/cmov/libc.so.6 (0xf7489000)
        libcgmanager.so.0 => /lib/i386-linux-gnu/libcgmanager.so.0 (0xf745b000)
        libnih.so.1 => /lib/libnih.so.1 (0xf7444000)
        libnih-dbus.so.1 => /lib/libnih-dbus.so.1 (0xf743b000)
        libdbus-1.so.3 => /lib/i386-linux-gnu/libdbus-1.so.3 (0xf73df000)
        /lib/ld-linux.so.2 (0x565b7000)
        libattr.so.1 => /lib/i386-linux-gnu/libattr.so.1 (0xf73d8000)
        libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xf7365000)
        libdl.so.2 => /lib/i386-linux-gnu/i686/cmov/libdl.so.2 (0xf7360000)
        librt.so.1 => /lib/i386-linux-gnu/i686/cmov/librt.so.1 (0xf7357000)
        libsystemd.so.0 => /lib/i386-linux-gnu/libsystemd.so.0 (0xf72c9000)
        libm.so.6 => /lib/i386-linux-gnu/i686/cmov/libm.so.6 (0xf7282000)
        libresolv.so.2 => /lib/i386-linux-gnu/i686/cmov/libresolv.so.2 (0xf726b000)
        liblzma.so.5 => /lib/i386-linux-gnu/liblzma.so.5 (0xf7242000)
        libgcrypt.so.20 => /lib/i386-linux-gnu/libgcrypt.so.20 (0xf7191000)
        libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf7174000)
        libgpg-error.so.0 => /lib/i386-linux-gnu/libgpg-error.so.0 (0xf715e000)

And

vasudev@rudra:~/Documents/Debian/collab-maint/lcdf-typetools$ dpkg -S /lib/i386-linux-gnu/libseccomp.so.2.2.3 
libseccomp2:i386: /lib/i386-linux-gnu/libseccomp.so.2.2.3

@hallyn
Copy link
Member

hallyn commented Oct 2, 2015

Oh, I see. So your host is 32-bit userspace. I haven't looked (and won't be able to for a week) but I can easily imagine that case being mishandled in the lxc seccomp code.

@hallyn
Copy link
Member

hallyn commented Nov 12, 2015

The problem occurs when:

  1. lxc checks uname, which is returning x86_64 for you.
  2. lxc decides to create a 32-bit compat context for you
    (using get_new_ctx())
    2a. seccomp creates a context for 32-bit x86
    2b. lxc adds SCMP_ARCH_X86 to the list of arches for that rule, but
    that was already there

I'm still trying to decide what lxc should do differently. You can
most easily get past this problem bug adding a check for

seccomp_arch_exist(compat_ctx, arch)

before the seccomp_arch_add is called. But I'm wondering what we should
be doing for your case in general. Should we continue to create a (default)
64-bit and a (compat) 32-bit context?

hallyn added a commit to hallyn/lxc that referenced this issue Nov 12, 2015
lxc uses uname to check the kernel version.  Seccomp respects userspace.  In the case
of 32-bit userspace on 64-bit kernel, this was a bad combination.

When we run into that case, make sure that the compat seccomp context is 32-bit, and
the lxc->seccomp_ctx is the 64-bit.

Closes lxc#654

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
@copyninja
Copy link
Author

Thanks guys for fixing this issue!.

ksperis pushed a commit to ksperis/lxc that referenced this issue Dec 13, 2015
lxc uses uname to check the kernel version.  Seccomp respects userspace.  In the case
of 32-bit userspace on 64-bit kernel, this was a bad combination.

When we run into that case, make sure that the compat seccomp context is 32-bit, and
the lxc->seccomp_ctx is the 64-bit.

Closes lxc#654

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
@evgeni
Copy link
Contributor

evgeni commented Mar 26, 2016

It seems 473ebc7 was reverted again and thus this issue still persists?

@copyninja @stgraber shall this be reopened again?

@copyninja
Copy link
Author

@evgeni Is the reverted lxc released?. I basically first tested this on lxc shipped from Debian so if its really reverted then I think issue needs to be reopened.

@evgeni
Copy link
Contributor

evgeni commented Mar 26, 2016

@copyninja as far as I can tell even the fixed one is not released as both commits are only in the 2.0 (master) branch.

@copyninja
Copy link
Author

@evgeni that is bad :(. If the fix is reverted I think this issue should be reopened but I can't do it.

z-image pushed a commit to z-image/lxc that referenced this issue Oct 16, 2016
lxc uses uname to check the kernel version.  Seccomp respects userspace.  In the case
of 32-bit userspace on 64-bit kernel, this was a bad combination.

When we run into that case, make sure that the compat seccomp context is 32-bit, and
the lxc->seccomp_ctx is the 64-bit.

Closes lxc#654

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
stgraber pushed a commit that referenced this issue Nov 18, 2016
lxc uses uname to check the kernel version.  Seccomp respects userspace.  In the case
of 32-bit userspace on 64-bit kernel, this was a bad combination.

When we run into that case, make sure that the compat seccomp context is 32-bit, and
the lxc->seccomp_ctx is the 64-bit.

Closes #654

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
@nboullis
Copy link

Hi,

For those who are interested, I could patch debian’s LXC 1:1.0.6-6+deb8u5 to run on a i386 userspace with an amd64 kernel. The patch is here: 0099-seccomp-64bit-kernel-32bit-userspace.patch

For more info, see my comment.

brauner pushed a commit to brauner/lxc that referenced this issue Apr 13, 2018
This commit deals with different kernel and userspace layouts and nesting. Here
are three examples:
1. 64bit kernel and 64bit userspace running 32bit containers
2. 64bit kernel and 32bit userspace running 64bit containers
3. 64bit kernel and 64bit userspace running 32bit containers running 64bit containers
Two things to lookout for:
1. The compat arch that is detected might have already been present in the main
   context. So check that it actually hasn't been and only then add it.
2. The contexts don't need merging if the architectures are the same and also can't be.
With these changes I can run all crazy/weird combinations with proper seccomp
isolation.

Closes lxc#654.

Link: https://bugs.chromium.org/p/chromium/issues/detail?id=832366
Reported-by: Chirantan Ekbote <chirantan@chromium.org>
Reported-by: Sonny Rao <sonnyrao@chromium.org>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
@brauner
Copy link
Member

brauner commented Apr 13, 2018

@copyninja, @nboullis, @evgeni see #2274 and #2275.

brauner pushed a commit that referenced this issue Apr 20, 2018
This commit deals with different kernel and userspace layouts and nesting. Here
are three examples:
1. 64bit kernel and 64bit userspace running 32bit containers
2. 64bit kernel and 32bit userspace running 64bit containers
3. 64bit kernel and 64bit userspace running 32bit containers running 64bit containers
Two things to lookout for:
1. The compat arch that is detected might have already been present in the main
   context. So check that it actually hasn't been and only then add it.
2. The contexts don't need merging if the architectures are the same and also can't be.
With these changes I can run all crazy/weird combinations with proper seccomp
isolation.

Closes #654.

Link: https://bugs.chromium.org/p/chromium/issues/detail?id=832366
Reported-by: Chirantan Ekbote <chirantan@chromium.org>
Reported-by: Sonny Rao <sonnyrao@chromium.org>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
geaaru pushed a commit to geaaru/lxc that referenced this issue Jul 4, 2018
This commit deals with different kernel and userspace layouts and nesting. Here
are three examples:
1. 64bit kernel and 64bit userspace running 32bit containers
2. 64bit kernel and 32bit userspace running 64bit containers
3. 64bit kernel and 64bit userspace running 32bit containers running 64bit containers
Two things to lookout for:
1. The compat arch that is detected might have already been present in the main
   context. So check that it actually hasn't been and only then add it.
2. The contexts don't need merging if the architectures are the same and also can't be.
With these changes I can run all crazy/weird combinations with proper seccomp
isolation.

Closes lxc#654.

Link: https://bugs.chromium.org/p/chromium/issues/detail?id=832366
Reported-by: Chirantan Ekbote <chirantan@chromium.org>
Reported-by: Sonny Rao <sonnyrao@chromium.org>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants