// https://syzkaller.appspot.com/bug?id=c620fe14aac810396d3c3edc9ad73848bf69a29e // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #ifndef __NR_ioctl #define __NR_ioctl 54 #endif #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_openat #define __NR_openat 295 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 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 { char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x1ffff000, 0x1000, 0, 0x32, -1, 0); syscall(__NR_mmap, 0x20000000, 0x1000000, 7, 0x32, -1, 0); syscall(__NR_mmap, 0x21000000, 0x1000, 0, 0x32, -1, 0); intptr_t res = 0; memcpy((void*)0x20000040, "/dev/loop#\000", 11); res = -1; res = syz_open_dev(0x20000040, 0x12f, 0); if (res != -1) r[0] = res; memcpy((void*)0x20000000, "/proc/self/exe\000", 15); res = syscall(__NR_openat, 0xffffff9c, 0x20000000, 0, 0); if (res != -1) r[1] = res; *(uint32_t*)0x20000180 = r[1]; *(uint32_t*)0x20000184 = 0; *(uint64_t*)0x20000188 = 0x10; *(uint64_t*)0x20000190 = 0; *(uint64_t*)0x20000198 = 0; *(uint64_t*)0x200001a0 = 0xd70e000000000000; *(uint64_t*)0x200001a8 = 0; *(uint32_t*)0x200001b0 = 0; *(uint32_t*)0x200001b4 = 0; *(uint32_t*)0x200001b8 = 0; *(uint32_t*)0x200001bc = 0x19; memcpy((void*)0x200001c0, "\x00\xfe\x6e\xae\x97\x0f\x2f\xfb\xf9\x90\xa9\xdc\x99\x79\xd4\x4e\x70" "\xe8\x20\xc0\xbe\xb9\x06\xd4\x64\x97\xe2\xdc\x63\x4c\xd3\xf6\x03\xee" "\x14\xbe\xeb\x05\x3d\xe5\x31\xb8\xaf\xca\x9e\x36\x8a\x23\xde\xfa\xcb" "\x73\xec\x8d\x0b\x50\x67\x10\x03\xb1\x1a\x91\xdb\x99", 64); memcpy((void*)0x20000200, "\xfb\xa2\x45\x88\xcb\x82\xcf\x3c\x4a\xb0\x7e\xfb\x8f\x6b\x23\x4e\xc8" "\x1d\x30\x00\x00\x86\xfb\x28\x8e\x1a\x33\x85\x88\x73\x34\x78\xbb\x4d" "\x24\x3d\xa9\xce\x8b\x06\x2d\x48\xa1\x01\xb9\x27\x50\x9b\x7a\xff\xa2" "\xdb\xc2\x5e\x3e\x96\xc0\xbe\xb5\x65\x89\xa6\xf6\x22", 64); memcpy((void*)0x20000240, "\x1b\xed\x9d\xb6\x70\x07\x39\xb2\xdb\xf5\xf7\xc5\xfe\xa5\xed\x84\xaf" "\xdb\xda\xf6\x22\x6a\x7d\x3f\x33\x53\x95\x84\x86\xf0\xfb\xc0", 32); *(uint64_t*)0x20000260 = 0; *(uint64_t*)0x20000268 = 0; memset((void*)0x20000270, 0, 64); syscall(__NR_ioctl, (intptr_t)r[0], 0x4c0a, 0x20000180); return 0; }