4

I am just simply trying to build an arm64 image of Kali Linux, but running into an issue with qemu. Everything seems to run fine with this image when building it for armv7l, but no luck with arm64.

I just installed qemu-user-static so it's running the latest version. Here's what my Dockerfile looks like (simply for testing purposes):

FROM kalilinux/kali-rolling

# Set environment variable for non-interactive install
ARG DEBIAN_FRONTEND=noninteractive

# Run basic commands to update the image and install basic stuff.
RUN apt update && \
  apt dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"

Here's my docker version:

ubuntu@ip-10-20-38-44:~$ docker -v
Docker version 20.10.6, build 370c289

Here's the command that I'm running to reproduce this error:

ubuntu@ip-10-20-38-44:~$ sudo docker buildx build -t [myusername]/test:latest --platform linux/arm64 .

Here's the error output that I get when I run the command above:

[+] Building 39.9s (5/5) FINISHED                                                                                                                                                                                                                                                                                                              
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                      0.0s 
 => => transferring dockerfile: 418B                                                                                                                                                                                                                                                                                                      0.0s 
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                         0.0s 
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                           0.0s 
 => [internal] load metadata for docker.io/kalilinux/kali-rolling:latest                                                                                                                                                                                                                                                                  0.4s 
 => CACHED [1/2] FROM docker.io/kalilinux/kali-rolling@sha256:bd098f211b325a7872c224a7eae755bb38332ea2d375376c75f10c0f194b8d8d                                                                                                                                                                                                            0.0s 
 => => resolve docker.io/kalilinux/kali-rolling@sha256:bd098f211b325a7872c224a7eae755bb38332ea2d375376c75f10c0f194b8d8d                                                                                                                                                                                                                   0.0s 
 => ERROR [2/2] RUN apt update &&   apt dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"                                                                                                                                                                                                        39.5s 
------                                                                                                                                                                                                                                                                                                                                         
 > [2/2] RUN apt update &&   apt dist-upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold":                                                                                                                                                                                                                    
#5 0.187                                                                                                                                                                                                                                                                                                                                       
#5 0.189 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.                                                                               
#5 0.189                                                                                                                                                               
#5 1.245 Get:1 http://mirrors.ocf.berkeley.edu/kali kali-rolling InRelease [30.5 kB]                                                                                   
#5 3.537 Get:2 http://mirrors.ocf.berkeley.edu/kali kali-rolling/contrib arm64 Packages [87.6 kB]                                                                      
#5 3.732 Get:3 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main arm64 Packages [17.5 MB]
#5 13.00 Get:4 http://mirrors.ocf.berkeley.edu/kali kali-rolling/non-free arm64 Packages [157 kB]                                                                      
#5 17.95 Fetched 17.8 MB in 18s (1008 kB/s)                                                                                                                            
#5 17.95 Reading package lists...                                                                                                                                      
#5 24.55 Building dependency tree...                                                                                                                                   
#5 25.32 Reading state information...                                                                                                                                  
#5 25.37 3 packages can be upgraded. Run 'apt list --upgradable' to see them.                                                                                          
#5 25.45                                                                                                                                                               
#5 25.45 WARNING: apt does not have a stable CLI interface. Use with caution in scripts.                                                                               
#5 25.45                                                                                                                                                               
#5 25.54 Reading package lists...                                                                                                                                      
#5 31.98 Building dependency tree...                                                                                                                                   
#5 32.76 Reading state information...                                                                                                                                  
#5 32.84 Calculating upgrade...                                                                                                                                        
#5 34.15 The following packages will be upgraded:                                                                                                                      
#5 34.15   kali-defaults libcrypt1 sysvinit-utils                                                                                                                                                                                                                                                                                              
#5 34.78 3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.                                                                                                                                                                                                                                                                        
#5 34.78 Need to get 593 kB of archives.                                           
#5 34.78 After this operation, 1024 B of additional disk space will be used.
#5 34.78 Get:1 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main arm64 sysvinit-utils arm64 2.96-7 [25.1 kB]                                                      
#5 34.90 Get:2 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main arm64 libcrypt1 arm64 1:4.4.18-2 [89.4 kB]
#5 34.98 Get:3 http://mirrors.ocf.berkeley.edu/kali kali-rolling/main arm64 kali-defaults all 2021.2.3 [479 kB]
#5 36.16 debconf: delaying package configuration, since apt-utils is not installed                                                                                     
#5 36.34 Fetched 593 kB in 1s (536 kB/s)                                                                                                                               
(Reading database ... 6748 files and directories currently installed.)                                                                                                 
#5 36.53 Preparing to unpack .../sysvinit-utils_2.96-7_arm64.deb ...                                                                                                   
#5 36.55 Unpacking sysvinit-utils (2.96-7) over (2.96-6) ...                                                                                                           
#5 36.76 Setting up sysvinit-utils (2.96-7) ...                       
(Reading database ... 6748 files and directories currently installed.)                                                                                                                                                                                                                                                                         
#5 37.00 Preparing to unpack .../libcrypt1_1%3a4.4.18-2_arm64.deb ...                                                                                                                                                                                                                                                                          
#5 37.03 Unpacking libcrypt1:arm64 (1:4.4.18-2) over (1:4.4.17-1) ...
#5 37.23 Setting up libcrypt1:arm64 (1:4.4.18-2) ...                   
(Reading database ... 6748 files and directories currently installed.)                                                                                                 
#5 37.47 Preparing to unpack .../kali-defaults_2021.2.3_all.deb ...  
#5 37.89 Unpacking kali-defaults (2021.2.3) over (2021.2.2) ...
#5 38.28 Setting up kali-defaults (2021.2.3) ...
#5 38.58 Configuring /etc/environment
#5 38.75 Processing triggers for libc-bin (2.31-9) ...
#5 38.81 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#5 39.02 Segmentation fault (core dumped)
#5 39.04 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#5 39.25 Segmentation fault (core dumped)
#5 39.26 dpkg: error processing package libc-bin (--configure):
#5 39.26  installed libc-bin package post-installation script subprocess returned error exit status 139
#5 39.27 Errors were encountered while processing:
#5 39.27  libc-bin
#5 39.34 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
Dockerfile:7

Everything runs perfectly fine if I switch arm64 to arm/v7. I tried to build this same Dockerfile from a Raspberry Pi that's running arm64 and no issues, so it's definitely got something to do with qemu, but just not sure what.

halfer
  • 19,824
  • 17
  • 99
  • 186
LewlSauce
  • 5,326
  • 8
  • 44
  • 91

1 Answers1

1

It seems that it's related to a bug in the kernel. The best explanation I could find was at https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1928075. Quoting Christian Ehrhardt in this discussion:

I've seen similar issues due to e.g. a newer glibc (could be any other program or even guest kernel) to use newer instructions and thereby trigger an issue that exists in the emulation.

I'm not sure, but this makes me think of the kernel maybe being related. Well this isn't system-virtualization, it is an emulation so the chances are much lower than usual, but might be worth a try.

I faced the same issue and tried a lot of different userland combinations (ie. different versions of Qemu, different Debian containers), to no avail. The only way to fix that was indeed to run a kernel recent enough. I'm with a Debian kernel 5.10.0-8-amd64 right now and it works.

What kernels did you try?

elboulangero
  • 818
  • 9
  • 18