Merge pull request #3305 from rn/kern-up

Add support for 5.0.x kernels and update to 4.20.15/4.19.28
This commit is contained in:
Justin Cormack
2019-03-18 12:07:15 +00:00
committed by GitHub
106 changed files with 12695 additions and 163 deletions

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,6 +1,6 @@
# NOTE: Images build from this file likely do not run
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -6,7 +6,7 @@ init:
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
onboot:
- name: check-kernel-config
image: linuxkit/test-kernel-config:85727fa0ad52861758230cd264059c79f657b953
image: linuxkit/test-kernel-config:e17f234c439535d1a297b020774301709adc5832
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "3"]

View File

@@ -6,7 +6,7 @@ init:
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
onboot:
- name: check-kernel-config
image: linuxkit/test-kernel-config:85727fa0ad52861758230cd264059c79f657b953
image: linuxkit/test-kernel-config:e17f234c439535d1a297b020774301709adc5832
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "3"]

View File

@@ -1,12 +1,12 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
onboot:
- name: check-kernel-config
image: linuxkit/test-kernel-config:85727fa0ad52861758230cd264059c79f657b953
image: linuxkit/test-kernel-config:e17f234c439535d1a297b020774301709adc5832
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "3"]

View File

@@ -1,12 +1,12 @@
kernel:
image: linuxkit/kernel:4.20.14
image: linuxkit/kernel:4.20.15
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
onboot:
- name: check-kernel-config
image: linuxkit/test-kernel-config:85727fa0ad52861758230cd264059c79f657b953
image: linuxkit/test-kernel-config:e17f234c439535d1a297b020774301709adc5832
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "3"]

View File

@@ -0,0 +1,24 @@
#!/bin/sh
# SUMMARY: Sanity check on the kernel config file
# LABELS:
# REPEAT:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=kconfig
clean_up() {
rm -rf ${NAME}-*
}
trap clean_up EXIT
# Test code goes here
linuxkit build -format kernel+initrd -name "${NAME}" test.yml
RESULT="$(linuxkit run ${NAME})"
echo "${RESULT}" | grep -q "suite PASSED"
exit 0

View File

@@ -0,0 +1,15 @@
kernel:
image: linuxkit/kernel:5.0.1
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:005807f5c6a74e23f485a6d1657818bdccb70cd0
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
onboot:
- name: check-kernel-config
image: linuxkit/test-kernel-config:e17f234c439535d1a297b020774301709adc5832
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "3"]
trust:
org:
- linuxkit

View File

@@ -3,7 +3,7 @@
# In the last stage, it creates a package, which can be used for
# testing.
FROM linuxkit/kernel:4.19.27 AS ksrc
FROM linuxkit/kernel:4.19.28 AS ksrc
# Extract headers and compile module
FROM linuxkit/alpine:5ce235f4fb55772e7f78871a70bfe26f774fe2b0 AS build

View File

@@ -19,7 +19,7 @@ clean_up() {
trap clean_up EXIT
# Make sure we have the latest kernel image
docker pull linuxkit/kernel:4.19.27
docker pull linuxkit/kernel:4.19.28
# Build a package
docker build -t ${IMAGE_NAME} .

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -3,7 +3,7 @@
# In the last stage, it creates a package, which can be used for
# testing.
FROM linuxkit/kernel:4.20.14 AS ksrc
FROM linuxkit/kernel:4.20.15 AS ksrc
# Extract headers and compile module
FROM linuxkit/alpine:5ce235f4fb55772e7f78871a70bfe26f774fe2b0 AS build

View File

@@ -19,7 +19,7 @@ clean_up() {
trap clean_up EXIT
# Make sure we have the latest kernel image
docker pull linuxkit/kernel:4.20.14
docker pull linuxkit/kernel:4.20.15
# Build a package
docker build -t ${IMAGE_NAME} .

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.20.14
image: linuxkit/kernel:4.20.15
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -0,0 +1,23 @@
# This Dockerfile extracts the kernel headers from the kernel image
# and then compiles a simple hello world kernel module against them.
# In the last stage, it creates a package, which can be used for
# testing.
FROM linuxkit/kernel:5.0.1 AS ksrc
# Extract headers and compile module
FROM linuxkit/alpine:5ce235f4fb55772e7f78871a70bfe26f774fe2b0 AS build
RUN apk add build-base libelf-dev
COPY --from=ksrc /kernel-dev.tar /
RUN tar xf kernel-dev.tar
WORKDIR /kmod
COPY ./src/* ./
RUN make all
# Package
FROM alpine:3.9
COPY --from=build /kmod/hello_world.ko /
COPY check.sh /check.sh
ENTRYPOINT ["/bin/sh", "/check.sh"]

View File

@@ -0,0 +1,15 @@
#!/bin/sh
function failed {
printf "Kernel module test suite FAILED\n"
/sbin/poweroff -f
}
uname -a
modinfo hello_world.ko || failed
insmod hello_world.ko || failed
[ -n "$(dmesg | grep -o 'Hello LinuxKit')" ] || failed
rmmod hello_world || failed
printf "Kernel module test suite PASSED\n"
/sbin/poweroff -f

View File

@@ -0,0 +1,6 @@
obj-m += hello_world.o
KVER=$(shell basename /usr/src/linux-headers-*)
all:
make -C /usr/src/$(KVER) M=$(PWD) modules
clean:
make -C /usr/src/$(KVER) M=$(PWD) clean

View File

@@ -0,0 +1,22 @@
/*
* A simple Hello World kernel module
*/
#include <linux/module.h>
#include <linux/kernel.h>
int init_hello(void)
{
printk(KERN_INFO "Hello LinuxKit\n");
return 0;
}
void exit_hello(void)
{
printk(KERN_INFO "Goodbye LinuxKit.\n");
}
module_init(init_hello);
module_exit(exit_hello);
MODULE_AUTHOR("Rolf Neugebauer <rolf.neugebauer@docker.com>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("A simple Hello World kernel module for testing");

View File

@@ -0,0 +1,31 @@
#!/bin/sh
# SUMMARY: Test build and insertion of kernel modules
# LABELS:
# REPEAT:
set -e
# Source libraries. Uncomment if needed/defined
#. "${RT_LIB}"
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
NAME=kmod
IMAGE_NAME=kmod-test
clean_up() {
docker rmi ${IMAGE_NAME} || true
rm -rf ${NAME}-*
}
trap clean_up EXIT
# Make sure we have the latest kernel image
docker pull linuxkit/kernel:5.0.1
# Build a package
docker build -t ${IMAGE_NAME} .
# Build and run a LinuxKit image with kernel module (and test script)
linuxkit build -format kernel+initrd -name "${NAME}" test.yml
RESULT="$(linuxkit run ${NAME})"
echo "${RESULT}" | grep -q "Hello LinuxKit"
exit 0

View File

@@ -0,0 +1,20 @@
kernel:
image: linuxkit/kernel:5.0.1
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:005807f5c6a74e23f485a6d1657818bdccb70cd0
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
onboot:
- name: check
image: kmod-test
binds:
- /dev:/dev
- /lib/modules:/lib/modules
capabilities:
- all
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "3"]
trust:
org:
- linuxkit

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 page_poison=1"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:v0.5

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,10 +1,10 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0 console=ttyAMA0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff
- linuxkit/runc:606971451ea29b4238029804ca638f9f85caf5af
- linuxkit/kernel-bcc:4.19.27
- linuxkit/kernel-bcc:4.19.28
onboot:
- name: check-bcc
image: alpine:3.9

View File

@@ -1,5 +1,5 @@
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff

View File

@@ -1,7 +1,7 @@
# FIXME: This should use the minimal example
# We continue to use the kernel-config-test as CI is currently expecting to see a success message
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff
@@ -12,7 +12,7 @@ onboot:
image: linuxkit/dhcpcd:85738d3d2f152a7879e17a61444f7714b858c2ee
command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"]
- name: check-kernel-config
image: linuxkit/test-kernel-config:85727fa0ad52861758230cd264059c79f657b953
image: linuxkit/test-kernel-config:e17f234c439535d1a297b020774301709adc5832
- name: poweroff
image: linuxkit/poweroff:9f4e04f09bbb4a028f0a1f57d430e1ad3095ace1
command: ["/bin/sh", "/poweroff.sh", "120"]

View File

@@ -3,8 +3,8 @@ FROM linuxkit/alpine:5ce235f4fb55772e7f78871a70bfe26f774fe2b0 AS mirror
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
RUN apk add --no-cache --initdb -p /out alpine-baselayout busybox musl bash
ENV DOCKER_CHECK_CONFIG_COMMIT=72cda6a6c2f25854bea2d69168082684f2c9feca
ADD https://raw.githubusercontent.com/docker/docker/${DOCKER_CHECK_CONFIG_COMMIT}/contrib/check-config.sh /out/check-config.sh
ENV MOBY_CHECK_CONFIG_COMMIT=38005cfc12fb6bdcff359c25e8fe05f2944b0d49
ADD https://raw.githubusercontent.com/moby/moby/${MOBY_CHECK_CONFIG_COMMIT}/contrib/check-config.sh /out/check-config.sh
ADD . ./out
RUN mkdir -p /out/lib/modules

View File

@@ -3,8 +3,8 @@
set -e
function fail {
printf "FAILURE: $1\n"
FAILED=1
printf "FAILURE: $1\n"
FAILED=1
}
echo "starting kernel config sanity test with ${1:-/proc/config.gz}"
@@ -16,7 +16,11 @@ else
UNZIPPED_CONFIG=$(zcat /proc/config.gz)
fi
kernelVersion="$(uname -r)"
if [ -n "$2" ]; then
kernelVersion="$2"
else
kernelVersion="$(uname -r)"
fi
kernelMajor="${kernelVersion%%.*}"
kernelMinor="${kernelVersion#$kernelMajor.}"
kernelMinor="${kernelMinor%%.*}"
@@ -42,81 +46,76 @@ echo $UNZIPPED_CONFIG | grep -q CONFIG_BPF_JIT_ALWAYS_ON=y || fail "CONFIG_BPF_J
# Conditional on kernel version
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 5 ]; then
if [ "$kernelMajor" -eq 4 -a "$kernelMinor" -le 10 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_DEBUG_RODATA=y || fail "CONFIG_DEBUG_RODATA=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_DEBUG_SET_MODULE_RONX=y || fail "CONFIG_DEBUG_SET_MODULE_RONX=y"
fi
# Options added in newer kernels
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_UBSAN=y || fail "CONFIG_UBSAN=y"
fi
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 7 ]; then
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 7 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_SLAB_FREELIST_RANDOM=y || fail "CONFIG_SLAB_FREELIST_RANDOM=y"
fi
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 8 ]; then
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 8 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_HARDENED_USERCOPY=y || fail "CONFIG_HARDENED_USERCOPY=y"
fi
# 4.16.x removed this option
if [ "$kernelMajor" -le 4 -a "$kernelMinor" -le 15 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_CC_STACKPROTECTOR=y || fail "CONFIG_CC_STACKPROTECTOR=y"
fi
# 4.18.x renamed this option (and re-introduced CC_STACKPROTECTOR as STACKPROTECTOR)
if [ "$kernelMajor" -le 4 -a "$kernelMinor" -ge 18 ]; then
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -le 4 -a "$kernelMinor" -ge 18 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_STACKPROTECTOR=y || fail "CONFIG_STACKPROTECTOR=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_STACKPROTECTOR_STRONG=y || fail "CONFIG_STACKPROTECTOR_STRONG=y"
else
echo $UNZIPPED_CONFIG | grep -q CONFIG_CC_STACKPROTECTOR_STRONG=y || fail "CONFIG_CC_STACKPROTECTOR_STRONG=y"
fi
# Positive cases conditional on architecture and/or kernel version
if [ "$arch" = "x86_64" ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_LEGACY_VSYSCALL_NONE=y || fail "CONFIG_LEGACY_VSYSCALL_NONE=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_PAGE_TABLE_ISOLATION=y || fail "CONFIG_PAGE_TABLE_ISOLATION=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_RETPOLINE=y || fail "CONFIG_RETPOLINE=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_GENERIC_CPU_VULNERABILITIES=y || fail "CONFIG_GENERIC_CPU_VULNERABILITIES=y"
fi
if [ "$arch" = "x86_64" -a "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_IO_STRICT_DEVMEM=y || fail "CONFIG_IO_STRICT_DEVMEM=y"
fi
if [ "$arch" = "x86_64" -a "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 8 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_RANDOMIZE_MEMORY=y || fail "CONFIG_RANDOMIZE_MEMORY=y"
fi
if [ "$arch" = "x86_64" ] || [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_RANDOMIZE_BASE=y || fail "CONFIG_RANDOMIZE_BASE=y"
fi
# poisoning cannot be enabled in 4.4
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 9 ]; then
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 9 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_PAGE_POISONING=y || fail "CONFIG_PAGE_POISONING=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_PAGE_POISONING_NO_SANITY=y || fail "CONFIG_PAGE_POISONING_NO_SANITY=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_PAGE_POISONING_ZERO=y || fail "CONFIG_PAGE_POISONING_ZERO=y"
fi
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 10 ]; then
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 10 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_BUG_ON_DATA_CORRUPTION=y || fail "CONFIG_BUG_ON_DATA_CORRUPTION=y"
fi
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -le 10 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_DEBUG_RODATA=y || fail "CONFIG_DEBUG_RODATA=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_DEBUG_SET_MODULE_RONX=y || fail "CONFIG_DEBUG_SET_MODULE_RONX=y"
fi
if [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 11 ]; then
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 11 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_STRICT_KERNEL_RWX=y || fail "CONFIG_STRICT_KERNEL_RWX=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_STRICT_MODULE_RWX=y || fail "CONFIG_STRICT_MODULE_RWX=y"
fi
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_RANDOMIZE_BASE=y || fail "CONFIG_RANDOMIZE_BASE=y"
fi
# Positive cases conditional on architecture and/or kernel version
if [ "$arch" = "x86_64" ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_LEGACY_VSYSCALL_NONE=y || fail "CONFIG_LEGACY_VSYSCALL_NONE=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_PAGE_TABLE_ISOLATION=y || fail "CONFIG_PAGE_TABLE_ISOLATION=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_RETPOLINE=y || fail "CONFIG_RETPOLINE=y"
echo $UNZIPPED_CONFIG | grep -q CONFIG_GENERIC_CPU_VULNERABILITIES=y || fail "CONFIG_GENERIC_CPU_VULNERABILITIES=y"
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_IO_STRICT_DEVMEM=y || fail "CONFIG_IO_STRICT_DEVMEM=y"
fi
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 8 ]; then
echo $UNZIPPED_CONFIG | grep -q CONFIG_RANDOMIZE_MEMORY=y || fail "CONFIG_RANDOMIZE_MEMORY=y"
fi
fi
# Negative cases
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_COMPAT_BRK is not set' || fail "CONFIG_COMPAT_BRK is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_SCSI_PROC_FS is not set' || fail "CONFIG_SCSI_PROC_FS is not set"
# Negative cases conditional on architecture and/or kernel version
if [ "$arch" = "x86_64" ]; then
if [ "$arch" = "x86_64" ]; then
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_ACPI_CUSTOM_METHOD is not set' || fail "CONFIG_ACPI_CUSTOM_METHOD is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_DEVKMEM is not set' || fail "CONFIG_DEVKMEM is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_COMPAT_VDSO is not set' || fail "CONFIG_COMPAT_VDSO is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_KEXEC is not set' || fail "CONFIG_KEXEC is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_X86_X32 is not set' || fail "CONFIG_X86_X32 is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_MODIFY_LDT_SYSCALL is not set' || fail "CONFIG_MODIFY_LDT_SYSCALL is not set"
fi
if [ "$arch" = "x86_64" ] || [ "$kernelMajor" -ge 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_LEGACY_PTYS is not set' || fail "CONFIG_LEGACY_PTYS is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_HIBERNATION is not set' || fail "CONFIG_HIBERNATION is not set"
if [ "$kernelMajor" -eq 5 ] || [ "$kernelMajor" -eq 4 -a "$kernelMinor" -ge 5 ]; then
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_LEGACY_PTYS is not set' || fail "CONFIG_LEGACY_PTYS is not set"
echo $UNZIPPED_CONFIG | grep -q 'CONFIG_HIBERNATION is not set' || fail "CONFIG_HIBERNATION is not set"
fi
fi
# modprobe
@@ -125,7 +124,7 @@ nfs \
nfsd \
ntfs
do
modprobe $mod 2>/dev/null || true
modprobe $mod 2>/dev/null || true
done
# check filesystems that are built in

View File

@@ -6,6 +6,13 @@ function failed {
}
/check-kernel-config.sh || failed
bash /check-config.sh || failed
# Skip moby kernel checks on 5.x kernels for now.
# See: https://github.com/moby/moby/issues/38887
kernelVersion="$(uname -r)"
kernelMajor="${kernelVersion%%.*}"
if [ "$kernelMajor" -lt 5 ]; then
bash /check-config.sh || failed
fi
printf "Kernel config test suite PASSED\n"

View File

@@ -1,6 +1,6 @@
# Sample YAML file for manual testing
kernel:
image: linuxkit/kernel:4.19.27
image: linuxkit/kernel:4.19.28
cmdline: "console=ttyS0"
init:
- linuxkit/init:629fdad56e62ae72bf8becf0c8a668241480d3ff