// https://syzkaller.appspot.com/bug?id=bdf08cae172f0f4572f6559e7d64f13fbebb708a // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static long syz_open_procfs(volatile long a0, volatile long a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == -1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); intptr_t res = 0; memcpy((void*)0x20000100, "syscall\000", 8); syz_open_procfs(0, 0x20000100); res = syscall(__NR_socket, 0x10ul, 3ul, 0); if (res != -1) r[0] = res; res = syscall(__NR_socket, 1ul, 0x803ul, 0); if (res != -1) r[1] = res; *(uint32_t*)0x200002c0 = 0x14; res = syscall(__NR_getsockname, r[1], 0x20000100ul, 0x200002c0ul); if (res != -1) r[2] = *(uint32_t*)0x20000104; *(uint64_t*)0x20000080 = 0; *(uint32_t*)0x20000088 = 0; *(uint64_t*)0x20000090 = 0x20000000; *(uint64_t*)0x20000000 = 0x20000580; *(uint32_t*)0x20000580 = 0x74; *(uint16_t*)0x20000584 = 0x10; *(uint16_t*)0x20000586 = 0x401; *(uint32_t*)0x20000588 = 0x70bd25; *(uint32_t*)0x2000058c = 0x25dfdbfd; *(uint8_t*)0x20000590 = 0; *(uint8_t*)0x20000591 = 0; *(uint16_t*)0x20000592 = 0; *(uint32_t*)0x20000594 = r[2]; *(uint32_t*)0x20000598 = 0; *(uint32_t*)0x2000059c = 0; *(uint16_t*)0x200005a0 = 0x4c; STORE_BY_BITMASK(uint16_t, , 0x200005a2, 0x12, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200005a3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200005a3, 1, 7, 1); *(uint16_t*)0x200005a4 = 0xb; *(uint16_t*)0x200005a6 = 1; memcpy((void*)0x200005a8, "batadv\000", 7); *(uint16_t*)0x200005b0 = 0x3c; STORE_BY_BITMASK(uint16_t, , 0x200005b2, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200005b3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200005b3, 1, 7, 1); *(uint16_t*)0x200005b4 = 0xc; *(uint16_t*)0x200005b6 = 1; memcpy((void*)0x200005b8, "BATMAN_V", 8); *(uint16_t*)0x200005c0 = 0xd; *(uint16_t*)0x200005c2 = 1; memcpy((void*)0x200005c4, "BATMAN_IV", 9); *(uint16_t*)0x200005d0 = 0xd; *(uint16_t*)0x200005d2 = 1; memcpy((void*)0x200005d4, "BATMAN_IV", 9); *(uint16_t*)0x200005e0 = 0xc; *(uint16_t*)0x200005e2 = 1; memcpy((void*)0x200005e4, "BATMAN_V", 8); *(uint16_t*)0x200005ec = 8; *(uint16_t*)0x200005ee = 3; *(uint32_t*)0x200005f0 = r[2]; *(uint64_t*)0x20000008 = 0x74; *(uint64_t*)0x20000098 = 1; *(uint64_t*)0x200000a0 = 0; *(uint64_t*)0x200000a8 = 0; *(uint32_t*)0x200000b0 = 0; syscall(__NR_sendmsg, r[0], 0x20000080ul, 0x20040000ul); return 0; }