aboutsummaryrefslogtreecommitdiffstats
path: root/tools/create-gce-image.sh
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-07-17 12:36:05 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-07-17 12:39:11 +0200
commitcc1c342923b30616acc9344fe5eade7eb1412850 (patch)
tree10899cc66516fcfc9e63acfa0c64218a5e6bd840 /tools/create-gce-image.sh
parente489b6cafdd3702f6d14307ae2f2278c3c2f6783 (diff)
syz-ci: allow to specify cmdline/sysctls
Allow to specify per-kernel command line and sysctl values to more closely mimic the target kernel.
Diffstat (limited to 'tools/create-gce-image.sh')
-rwxr-xr-xtools/create-gce-image.sh25
1 files changed, 20 insertions, 5 deletions
diff --git a/tools/create-gce-image.sh b/tools/create-gce-image.sh
index 3329fcfe0..dccab5f7b 100755
--- a/tools/create-gce-image.sh
+++ b/tools/create-gce-image.sh
@@ -17,6 +17,11 @@
# Usage:
# ./create-gce-image.sh /dir/with/user/space/system /path/to/bzImage
#
+# If SYZ_SYSCTL_FILE env var is set and points to a file,
+# then its contents will be appended to the image /etc/sysctl.conf.
+# If SYZ_CMDLINE_FILE env var is set and points to a file,
+# then its contents will be appended to the kernel command line.
+#
# Outputs are (in the current dir):
# - disk.raw: the image
# - key: root ssh key
@@ -66,11 +71,14 @@ sudo sed -i "/^root/ { s/:x:/::/ }" disk.mnt/etc/passwd
echo "T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100" | sudo tee -a disk.mnt/etc/inittab
echo -en "auto lo\niface lo inet loopback\nauto eth0\niface eth0 inet dhcp\n" | sudo tee disk.mnt/etc/network/interfaces
echo "debugfs /sys/kernel/debug debugfs defaults 0 0" | sudo tee -a disk.mnt/etc/fstab
+
+# sysctls
echo "kernel.printk = 7 4 1 3" | sudo tee -a disk.mnt/etc/sysctl.conf
echo "debug.exception-trace = 0" | sudo tee -a disk.mnt/etc/sysctl.conf
-echo "net.core.bpf_jit_enable = 1" | sudo tee -a disk.mnt/etc/sysctl.conf
-echo "net.core.bpf_jit_harden = 2" | sudo tee -a disk.mnt/etc/sysctl.conf
-echo "net.ipv4.ping_group_range = 0 65535" | sudo tee -a disk.mnt/etc/sysctl.conf
+if [ -f $SYZ_SYSCTL_FILE ]; then
+ cat $SYZ_SYSCTL_FILE | sudo tee -a disk.mnt/etc/sysctl.conf
+fi
+
echo -en "127.0.0.1\tlocalhost\n" | sudo tee disk.mnt/etc/hosts
echo "nameserver 8.8.8.8" | sudo tee -a disk.mnt/etc/resolve.conf
echo "ClientAliveInterval 420" | sudo tee -a disk.mnt/etc/ssh/sshd_config
@@ -81,11 +89,18 @@ sudo mkdir -p disk.mnt/root/.ssh
sudo cp key.pub disk.mnt/root/.ssh/authorized_keys
sudo chown root disk.mnt/root/.ssh/authorized_keys
sudo mkdir -p disk.mnt/boot/grub
+
+CMDLINE=""
+if [ -f $SYZ_CMDLINE_FILE ]; then
+ CMDLINE=$(awk '{printf("%s ", $0)}' $SYZ_CMDLINE_FILE)
+fi
+
cat << EOF | sudo tee disk.mnt/boot/grub/grub.cfg
terminal_input console
terminal_output console
set timeout=0
-# vsyscall=native: required to run x86_64 executables on android kernels (for some reason they disable VDSO by default)
+# vsyscall=native: required to run x86_64 executables on android kernels
+# (for some reason they disable VDSO by default)
# rodata=n: mark_rodata_ro becomes very slow with KASAN (lots of PGDs)
# panic=86400: prevents kernel from rebooting so that we don't get reboot output in all crash reports
# debug is not set as it produces too much output
@@ -98,7 +113,7 @@ menuentry 'linux' --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,1)'
- linux /vmlinuz root=/dev/sda1 console=ttyS0 earlyprintk=serial vsyscall=native rodata=n ftrace_dump_on_oops=orig_cpu oops=panic panic_on_warn=1 nmi_watchdog=panic panic=86400 kvm-intel.nested=1 kvm-intel.unrestricted_guest=1 kvm-intel.vmm_exclusive=1 kvm-intel.fasteoi=1 kvm-intel.ept=1 kvm-intel.flexpriority=1 kvm-intel.vpid=1 kvm-intel.emulate_invalid_guest_state=1 kvm-intel.eptad=1 kvm-intel.enable_shadow_vmcs=1 kvm-intel.pml=1 kvm-intel.enable_apicv=1
+ linux /vmlinuz root=/dev/sda1 console=ttyS0 earlyprintk=serial vsyscall=native rodata=n ftrace_dump_on_oops=orig_cpu oops=panic panic_on_warn=1 nmi_watchdog=panic panic=86400 $CMDLINE
}
EOF
sudo grub-install --boot-directory=disk.mnt/boot --no-floppy /dev/nbd0