// https://syzkaller.appspot.com/bug?id=4006bcda50967d109d7512134751ca8fb84d393f // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t 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)); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static void test(); void loop() { while (1) { test(); } } #ifndef __NR_ioctl #define __NR_ioctl 54 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 356 #endif #ifndef __NR_mmap #define __NR_mmap 192 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 long r[3]; void test() { memset(r, -1, sizeof(r)); syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); memcpy((void*)0x20e6aff5, "/dev/loop#", 11); r[0] = syz_open_dev(0x20e6aff5, 0, 0); *(uint32_t*)0x20a19f74 = 0; *(uint32_t*)0x20a19f78 = 0; *(uint32_t*)0x20a19f7c = 0; *(uint32_t*)0x20a19f80 = 0; *(uint32_t*)0x20a19f84 = 1; *(uint32_t*)0x20a19f88 = 0; *(uint32_t*)0x20a19f8c = 5; *(uint32_t*)0x20a19f90 = 8; memcpy((void*)0x20a19f94, "\x2d\x40\xac\xaa\x6a\x60\x61\x01\x80\xfd\x8d\x61\x80\x37\xe6\xe7\xfe" "\x07\x8d\x8e\xcb\xfa\x12\xbb\xf5\x3c\xe2\x39\xdb\x16\xb7\xa6\x18\x6c" "\x8f\xb5\x52\x23\x22\x27\x33\x3f\x70\xa3\xce\x50\x2b\x0c\xc9\x88\x83" "\xed\x0e\xbc\x07\x6c\xba\x34\x7c\xb2\x4c\xf1\xc3\x37", 64); memcpy((void*)0x20a19fd4, "\x0c\x6e\xc4\xf4\x64\xda\x36\x04\x6e\x70\xfa\xa4" "\xc9\x67\x14\xf1\x7d\xb6\x15\x3d\xea\xe7\xcf\xb7" "\x0e\xaf\xb5\x18\x9b\xa1\x95\x56", 32); *(uint32_t*)0x20a19ff4 = -1; *(uint32_t*)0x20a19ff8 = 8; *(uint32_t*)0x20a19ffc = 0; syscall(__NR_ioctl, r[0], 0x4c02, 0x20a19f74); memcpy((void*)0x20e6aff5, "/dev/loop#", 11); r[1] = syz_open_dev(0x20e6aff5, 0, 0x101100); memcpy((void*)0x20515ff0, "\x74\x75\x6e\x08\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00", 16); r[2] = syscall(__NR_memfd_create, 0x20515ff0, 0); syscall(__NR_ioctl, r[1], 0x4c00, r[2]); } int main() { for (;;) { loop(); } }