github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/pkg/build/linux_generated.go (about) 1 // Code generated by pkg/build/linux.go. DO NOT EDIT. 2 3 package build 4 5 const createImageScript = `#!/bin/bash 6 7 8 set -eux 9 10 CLEANUP="" 11 trap 'eval " $CLEANUP"' EXIT 12 13 IMG_ARCH="${3:-amd64}" 14 15 if [ ! -e $1/sbin/init ]; then 16 echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage [arch]" 17 exit 1 18 fi 19 20 case "$IMG_ARCH" in 21 386|amd64|s390x) 22 KERNEL_IMAGE_BASENAME=bzImage 23 ;; 24 ppc64le) 25 KERNEL_IMAGE_BASENAME=zImage.pseries 26 ;; 27 esac 28 29 if [ "$(basename $2)" != "$KERNEL_IMAGE_BASENAME" ]; then 30 echo "usage: create-gce-image.sh /dir/with/user/space/system /path/to/bzImage [arch]" 31 exit 1 32 fi 33 34 BLOCK_DEVICE="loop" 35 if [ "$(uname -a | grep Ubuntu)" != "" ]; then 36 BLOCK_DEVICE="nbd" 37 fi 38 39 sudo umount disk.mnt || true 40 if [ "$BLOCK_DEVICE" == "loop" ]; then 41 : 42 elif [ "$BLOCK_DEVICE" == "nbd" ]; then 43 sudo modprobe nbd 44 sudo qemu-nbd -d /dev/nbd0 || true 45 fi 46 rm -rf disk.mnt disk.raw || true 47 48 fallocate -l 2G disk.raw 49 if [ "$BLOCK_DEVICE" == "loop" ]; then 50 DISKDEV="$(sudo losetup -f --show -P disk.raw)" 51 CLEANUP="sudo losetup -d $DISKDEV; $CLEANUP" 52 elif [ "$BLOCK_DEVICE" == "nbd" ]; then 53 DISKDEV="/dev/nbd0" 54 sudo qemu-nbd -c $DISKDEV --format=raw disk.raw 55 CLEANUP="sudo qemu-nbd -d $DISKDEV; $CLEANUP" 56 fi 57 58 case "$IMG_ARCH" in 59 386|amd64|s390x) 60 echo -en "o\nn\np\n1\n\n\na\nw\n" | sudo fdisk $DISKDEV 61 PARTDEV=$DISKDEV"p1" 62 ;; 63 ppc64le) 64 echo -en "o\nn\np\n1\n2048\n16383\na\nt\n41\nn\np\n2\n\n\nw\n" | sudo fdisk $DISKDEV 65 PARTDEV=$DISKDEV"p2" 66 ;; 67 esac 68 69 until [ -e $PARTDEV ]; do sleep 1; done 70 sudo -E mkfs.ext4 -O ^resize_inode,^has_journal,ext_attr,extents,huge_file,flex_bg,dir_nlink,sparse_super $PARTDEV 71 mkdir -p disk.mnt 72 CLEANUP="rm -rf disk.mnt; $CLEANUP" 73 sudo mount $PARTDEV disk.mnt 74 CLEANUP="sudo umount disk.mnt; $CLEANUP" 75 sudo cp -a $1/. disk.mnt/. 76 sudo cp $2 disk.mnt/vmlinuz 77 sudo sed -i "/^root/ { s/:x:/::/ }" disk.mnt/etc/passwd 78 echo "T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100" | sudo tee -a disk.mnt/etc/inittab 79 echo -en "auto lo\niface lo inet loopback\nauto eth0\niface eth0 inet dhcp\n" | sudo tee disk.mnt/etc/network/interfaces 80 echo '/dev/root / ext4 defaults 0 0' | sudo tee -a disk.mnt/etc/fstab 81 echo "debugfs /sys/kernel/debug debugfs defaults 0 0" | sudo tee -a disk.mnt/etc/fstab 82 echo "securityfs /sys/kernel/security securityfs defaults 0 0" | sudo tee -a disk.mnt/etc/fstab 83 echo "configfs /sys/kernel/config/ configfs defaults 0 0" | sudo tee -a disk.mnt/etc/fstab 84 echo 'binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0' | sudo tee -a disk.mnt/etc/fstab 85 for i in {0..31}; do 86 echo "KERNEL==\"binder$i\", NAME=\"binder$i\", MODE=\"0666\"" | \ 87 sudo tee -a disk.mnt/etc/udev/50-binder.rules 88 done 89 90 echo 'ATTR{name}=="vim2m", SYMLINK+="vim2m"' | sudo tee -a disk.mnt/etc/udev/rules.d/50-udev-default.rules 91 92 echo 'SUBSYSTEMS=="pci", DRIVERS=="i915", SYMLINK+="i915"' | sudo tee -a disk.mnt/etc/udev/rules.d/60-drm.rules 93 94 SYZ_SYSCTL_FILE="${SYZ_SYSCTL_FILE:-}" 95 if [ "$SYZ_SYSCTL_FILE" != "" ]; then 96 cat $SYZ_SYSCTL_FILE | sudo tee -a disk.mnt/etc/sysctl.conf 97 fi 98 99 echo -en "127.0.0.1\tlocalhost\n" | sudo tee disk.mnt/etc/hosts 100 echo "nameserver 8.8.8.8" | sudo tee -a disk.mnt/etc/resolv.conf 101 echo "syzkaller" | sudo tee disk.mnt/etc/hostname 102 sudo mkdir -p disk.mnt/boot/grub 103 104 cat << EOF | sudo tee disk.mnt/etc/ssh/sshd_config 105 PermitRootLogin yes 106 PasswordAuthentication yes 107 PermitEmptyPasswords yes 108 ClientAliveInterval 420 109 Subsystem sftp /usr/lib/openssh/sftp-server 110 EOF 111 sudo sed -i "s#^root:\*:#root::#g" disk.mnt/etc/shadow 112 113 CMDLINE="" 114 SYZ_CMDLINE_FILE="${SYZ_CMDLINE_FILE:-}" 115 if [ "$SYZ_CMDLINE_FILE" != "" ]; then 116 CMDLINE=$(awk '{printf("%s ", $0)}' $SYZ_CMDLINE_FILE) 117 fi 118 119 case "$IMG_ARCH" in 120 386|amd64) 121 cat << EOF | sudo tee disk.mnt/boot/grub/grub.cfg 122 terminal_input console 123 terminal_output console 124 set timeout=0 125 menuentry 'linux' --class gnu-linux --class gnu --class os { 126 insmod vbe 127 insmod vga 128 insmod video_bochs 129 insmod video_cirrus 130 insmod gzio 131 insmod part_msdos 132 insmod ext2 133 set root='(hd0,1)' 134 linux /vmlinuz root=/dev/sda1 console=ttyS0 earlyprintk=serial vsyscall=native net.ifnames=0 sysctl.kernel.hung_task_all_cpu_backtrace=1 $CMDLINE 135 } 136 EOF 137 sudo grub-install --target=i386-pc --boot-directory=disk.mnt/boot --no-floppy $DISKDEV 138 ;; 139 ppc64le) 140 cat << EOF | sudo tee disk.mnt/boot/grub/grub.cfg 141 terminal_input console 142 terminal_output console 143 set timeout=0 144 menuentry 'linux' --class gnu-linux --class gnu --class os { 145 insmod gzio 146 insmod part_msdos 147 insmod ext2 148 search -f --set /vmlinuz 149 linux /vmlinuz root=/dev/sda2 rootwait console=ttyS0 earlyprintk=serial oops=panic panic_on_warn=1 nmi_watchdog=panic panic=60 net.ifnames=0 $CMDLINE 150 } 151 EOF 152 sudo grub-install --target=powerpc-ieee1275 --boot-directory=disk.mnt/boot $DISKDEV"p1" 153 ;; 154 s390x) 155 sudo zipl -V -t disk.mnt/boot -i disk.mnt/vmlinuz \ 156 -P "root=/dev/vda1 console=ttyS0 earlyprintk=serial oops=panic panic_on_warn=1 nmi_watchdog=panic panic=86400 net.ifnames=0 sysctl.kernel.hung_task_all_cpu_backtrace=1 net.ifnames=0 biosdevname=0 $CMDLINE" \ 157 --targetbase=$DISKDEV --targettype=SCSI --targetblocksize=512 --targetoffset=2048 158 ;; 159 esac 160 `