// https://syzkaller.appspot.com/bug?id=cc48191274be0a9e986e29be2ef06fc176c4aa51 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } #define CAST static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; ((intptr_t(*)(intptr_t,intptr_t))CAST(truncate))(/*file=*/0, /*len=*/0xffffffff00000001); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(write))(/*fd=*/-1, /*buf=*/0, /*count=*/0); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(write))(/*fd=*/-1, /*buf=*/0, /*count=*/0); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(write))(/*fd=*/-1, /*buf=*/0, /*count=*/0); ((intptr_t(*)(intptr_t))CAST(close))(/*fd=*/-1); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(shmat))(/*shmid=*/0, /*addr=*/0x20fff000, /*flags=*/0); *(uint64_t*)0x20000000 = 0x10; *(uint64_t*)0x20000008 = 0; *(uint64_t*)0x20000010 = 0x20ffd000; *(uint64_t*)0x20000018 = 0x20ff3000; *(uint64_t*)0x20000020 = 0x20041000; *(uint64_t*)0x20000028 = 0x20538000; *(uint64_t*)0x20000030 = 0x20ffa000; *(uint64_t*)0x20000038 = 0x200000000; *(uint64_t*)0x20000040 = 0x201f5000; *(uint64_t*)0x20000048 = 0x20ffb000; *(uint64_t*)0x20000050 = 0; *(uint64_t*)0x20000058 = 0x20ffc000; *(uint64_t*)0x20000060 = 0x20ffc000; *(uint64_t*)0x20000068 = 0; *(uint64_t*)0x20000070 = 0x20ffb000; *(uint64_t*)0x20000078 = 0x20ffb000; *(uint64_t*)0x20000080 = 0; *(uint64_t*)0x20000088 = 0x20ffc000; *(uint64_t*)0x20000090 = 0x20ff3000; *(uint64_t*)0x20000098 = 0; *(uint64_t*)0x200000a0 = 0x20ff2000; *(uint64_t*)0x200000a8 = 0x200a0000; *(uint64_t*)0x200000b0 = 0; *(uint64_t*)0x200000b8 = 0x20ffe000; *(uint64_t*)0x200000c0 = 0x20ffe000; *(uint64_t*)0x200000c8 = 0; *(uint64_t*)0x200000d0 = 0; *(uint64_t*)0x200000d8 = 0x20ffa000; *(uint64_t*)0x200000e0 = 0; *(uint64_t*)0x200000e8 = 0x20ffe000; *(uint64_t*)0x200000f0 = 0x201f4000; *(uint64_t*)0x200000f8 = 0; *(uint64_t*)0x20000100 = 0x20002000; *(uint64_t*)0x20000108 = 0x20ff9000; *(uint64_t*)0x20000110 = 0; *(uint64_t*)0x20000118 = 0x20ffb000; *(uint64_t*)0x20000120 = 0x2009f000; *(uint64_t*)0x20000128 = 0; *(uint64_t*)0x20000130 = 0x20ffc000; *(uint64_t*)0x20000138 = 0x20084000; *(uint64_t*)0x20000140 = 0; *(uint64_t*)0x20000148 = 0x20160000; *(uint64_t*)0x20000150 = 0x20ffe000; *(uint64_t*)0x20000158 = 0; *(uint64_t*)0x20000160 = 0x20161000; *(uint64_t*)0x20000168 = 0x20ffa000; *(uint64_t*)0x20000170 = 0; *(uint64_t*)0x20000178 = 0x20ffd000; *(uint64_t*)0x20000180 = 0x20ffd000; *(uint64_t*)0x20000188 = 0; memcpy((void*)0x20000190, "./file0\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\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 64); *(uint32_t*)0x200001d0 = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/-1, /*cmd=*/0xc5005601, /*arg=*/0x20000000); memcpy((void*)0x20000280, "/dev/vmm\000", 9); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t))CAST(openat))(/*fd=*/0xffffffffffffff9c, /*file=*/0x20000280, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; *(uint32_t*)0x20000000 = 2; *(uint32_t*)0x20000004 = 0; *(uint8_t*)0x20000008 = 1; *(uint16_t*)0x2000000a = 0; *(uint64_t*)0x20000010 = 0; *(uint16_t*)0x20000018 = 0; *(uint8_t*)0x2000001a = 0; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(ioctl))(/*fd=*/r[0], /*cmd=*/0xc2585601, /*arg=*/0x20000000); } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x20000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); loop(); return 0; }