// https://syzkaller.appspot.com/bug?id=8fc4ac2bd63ac049e7a369676b65f047f65d7736 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2, 0); } } uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // openat$kvm arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6b 76 6d 00} (length 0x9) // } // flags: open_flags = 0x0 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_kvm memcpy((void*)0x200000000000, "/dev/kvm\000", 9); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000000ul, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; // ioctl$KVM_CREATE_VM arguments: [ // fd: fd_kvm (resource) // cmd: const = 0xae01 (4 bytes) // type: intptr = 0x0 (8 bytes) // ] // returns fd_kvmvm res = syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0xae01, /*type=*/0ul); if (res != -1) r[1] = res; // ioctl$KVM_XEN_HVM_CONFIG arguments: [ // fd: fd_kvmvm (resource) // cmd: const = 0x4038ae7a (4 bytes) // arg: ptr[in, kvm_xen_hvm_config] { // kvm_xen_hvm_config { // flags: int32 = 0x2 (4 bytes) // msr: msr_index = 0x40000105 (4 bytes) // addr32: nil // addr64: nil // size32: len = 0x0 (1 bytes) // size64: len = 0x0 (1 bytes) // pad: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1e) // } // } // ] *(uint32_t*)0x200000000040 = 2; *(uint32_t*)0x200000000044 = 0x40000105; *(uint64_t*)0x200000000048 = 0; *(uint64_t*)0x200000000050 = 0; *(uint8_t*)0x200000000058 = 0; *(uint8_t*)0x200000000059 = 0; memset((void*)0x20000000005a, 0, 30); syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x4038ae7a, /*arg=*/0x200000000040ul); // syz_open_dev$sndctrl arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 73 6e 64 2f 63 6f 6e 74 72 6f 6c 43 23 00} // (length 0x13) // } // id: intptr = 0x1 (8 bytes) // flags: open_flags = 0x0 (8 bytes) // ] // returns fd_sndctrl memcpy((void*)0x200000000100, "/dev/snd/controlC#\000", 19); res = -1; res = syz_open_dev(/*dev=*/0x200000000100, /*id=*/1, /*flags=*/0); if (res != -1) r[2] = res; // ioctl$SNDRV_CTL_IOCTL_ELEM_UNLOCK arguments: [ // fd: fd_sndctrl (resource) // cmd: const = 0xc1105511 (4 bytes) // arg: ptr[in, snd_ctl_elem_id] { // snd_ctl_elem_id { // numid: int32 = 0x7 (4 bytes) // iface: snd_ctl_iface = 0x3 (4 bytes) // dev: int32 = 0x40 (4 bytes) // subdev: int32 = 0x10000 (4 bytes) // name: buffer: {73 79 7a 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00} (length 0x2c) index: int32 = 0x4000041 (4 bytes) // } // } // ] *(uint32_t*)0x200000000040 = 7; *(uint32_t*)0x200000000044 = 3; *(uint32_t*)0x200000000048 = 0x40; *(uint32_t*)0x20000000004c = 0x10000; memcpy((void*)0x200000000050, "syz1\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000", 44); *(uint32_t*)0x20000000007c = 0x4000041; syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0xc1105511, /*arg=*/0x200000000040ul); // ioctl$KVM_CREATE_VCPU arguments: [ // fd: fd_kvmvm (resource) // cmd: const = 0xae41 (4 bytes) // id: intptr = 0x4 (8 bytes) // ] // returns fd_kvmcpu res = syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0xae41, /*id=*/4ul); if (res != -1) r[3] = res; // ioctl$KVM_SET_CPUID2 arguments: [ // fd: fd_kvmcpu (resource) // cmd: const = 0x4048aecb (4 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {07} (length 0x1) // } // } // } // ] memset((void*)0x200000000080, 7, 1); syscall(__NR_ioctl, /*fd=*/r[3], /*cmd=*/0x4048aecb, /*arg=*/0x200000000080ul); // ioctl$KVM_RUN arguments: [ // fd: fd_kvmcpu (resource) // cmd: const = 0xae80 (4 bytes) // arg: const = 0x0 (8 bytes) // ] syscall(__NR_ioctl, /*fd=*/r[3], /*cmd=*/0xae80, /*arg=*/0ul); return 0; }