// 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); } } #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 356 #endif #ifndef __NR_ioctl #define __NR_ioctl 54 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 long r[3]; void loop() { memset(r, -1, sizeof(r)); syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); memcpy((void*)0x20fb6000, "/dev/loop#", 11); r[0] = syz_open_dev(0x20fb6000, 0, 0x80080002); memcpy((void*)0x20d55ffd, "$'", 3); r[1] = syscall(__NR_memfd_create, 0x20d55ffd, 0); syscall(__NR_ioctl, r[0], 0x4c00, r[1]); memcpy((void*)0x20000000, "/dev/loop#", 11); r[2] = syz_open_dev(0x20000000, 0, 0); *(uint32_t*)0x20000000 = 0; *(uint32_t*)0x20000004 = 0; *(uint32_t*)0x20000008 = 0; *(uint32_t*)0x2000000c = 0; *(uint32_t*)0x20000010 = 0; *(uint32_t*)0x20000014 = 0; *(uint32_t*)0x20000018 = 0; *(uint32_t*)0x2000001c = 0xfffffffe; memcpy((void*)0x20000020, "\x21\xdb\xba\x96\x24\x54\x28\x1a\xc1\x4a\x7e\x86\x91\x0f\x46\x72\x51" "\x8a\xc2\x89\x90\x1e\x47\x2e\x1a\xad\xf2\x83\x33\xb7\xad\xf2\xe3\x2e" "\xb8\x7a\x81\x3c\xff\xff\xff\x07\x00\xff\xff\xfd\x75\x8a\xc0\x64\x9e" "\x0e\xba\x37\x3d\xa4\x80\x25\x4f\x8e\xc7\x00\x94\xac", 64); memcpy((void*)0x20000060, "\xf2\x31\x96\xfc\x66\x50\xfa\x74\x62\x6a\x57\xcb" "\xde\xfa\xff\x63\xc3\xd3\xdb\x8d\xbc\x9e\xd6\xd8" "\x5c\x84\xa7\xc1\x5c\x81\x3d\x8c", 32); *(uint32_t*)0x20000080 = 0; *(uint32_t*)0x20000084 = 0; *(uint32_t*)0x20000088 = 0; syscall(__NR_ioctl, r[2], 0x4c02, 0x20000000); } int main() { loop(); return 0; }