// https://syzkaller.appspot.com/bug?id=8f063539d4ecf1faf3132624b57a641e923ee25a // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1) #define BITMASK_LEN_OFF(type, bf_off, bf_len) \ (type)(BITMASK_LEN(type, (bf_len)) << (bf_off)) #define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \ if ((bf_off) == 0 && (bf_len) == 0) { \ *(type*)(addr) = (type)(val); \ } else { \ type new_val = *(type*)(addr); \ new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \ new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \ *(type*)(addr) = new_val; \ } struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i; for (i = 0; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += (uint16_t)data[length - 1]; while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); long res = 0; memcpy((void*)0x200002c0, "/dev/kvm", 9); res = syscall(__NR_openat, 0xffffffffffffff9c, 0x200002c0, 0, 0); if (res != -1) r[0] = res; res = syscall(__NR_ioctl, r[0], 0xae01, 0); if (res != -1) r[1] = res; res = syscall(__NR_ioctl, r[1], 0xae41, 0); if (res != -1) r[2] = res; syscall(__NR_ioctl, r[2], 0x4080aebf, 0x20000ec0); syscall(__NR_socketpair, 1, 3, 0, 0x20000240); *(uint8_t*)0x20000000 = 1; *(uint8_t*)0x20000001 = 0x80; *(uint8_t*)0x20000002 = 0xc2; *(uint8_t*)0x20000003 = 0; *(uint8_t*)0x20000004 = 0; *(uint8_t*)0x20000005 = 0; *(uint8_t*)0x20000006 = 0xaa; *(uint8_t*)0x20000007 = 0xaa; *(uint8_t*)0x20000008 = 0xaa; *(uint8_t*)0x20000009 = 0xaa; *(uint8_t*)0x2000000a = 0xaa; *(uint8_t*)0x2000000b = 0xaa; *(uint16_t*)0x2000000c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, 0x2000000e, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2000000e, 6, 4, 4); memcpy((void*)0x2000000f, "\x8b\xba\x30", 3); *(uint16_t*)0x20000012 = htobe16(0x10); *(uint8_t*)0x20000014 = 0; *(uint8_t*)0x20000015 = 0; *(uint8_t*)0x20000016 = 0xfe; *(uint8_t*)0x20000017 = 0x80; *(uint8_t*)0x20000018 = 0; *(uint8_t*)0x20000019 = 0; *(uint8_t*)0x2000001a = 0x3c; *(uint8_t*)0x2000001b = 0; *(uint8_t*)0x2000001c = 0; *(uint8_t*)0x2000001d = 0; *(uint8_t*)0x2000001e = 0; *(uint8_t*)0x2000001f = 0; *(uint8_t*)0x20000020 = 0; *(uint8_t*)0x20000021 = 0; *(uint8_t*)0x20000022 = 0; *(uint8_t*)0x20000023 = 0; *(uint8_t*)0x20000024 = 0; *(uint8_t*)0x20000025 = 0xbb; *(uint8_t*)0x20000026 = 0; *(uint8_t*)0x20000027 = 0; *(uint8_t*)0x20000028 = 0; *(uint8_t*)0x20000029 = 0; *(uint8_t*)0x2000002a = 0; *(uint8_t*)0x2000002b = 0; *(uint8_t*)0x2000002c = 0; *(uint8_t*)0x2000002d = 0; *(uint8_t*)0x2000002e = 0; *(uint8_t*)0x2000002f = 0; *(uint8_t*)0x20000030 = 0; *(uint8_t*)0x20000031 = 0; *(uint8_t*)0x20000032 = 0; *(uint8_t*)0x20000033 = 0; *(uint8_t*)0x20000034 = 0; *(uint8_t*)0x20000035 = 0; *(uint16_t*)0x20000036 = htobe16(0); *(uint16_t*)0x20000038 = htobe16(0); *(uint8_t*)0x2000003a = 4; STORE_BY_BITMASK(uint8_t, 0x2000003b, 1, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2000003b, 0, 4, 4); *(uint16_t*)0x2000003c = htobe16(0); STORE_BY_BITMASK(uint8_t, 0x2000003e, 0, 0, 1); STORE_BY_BITMASK(uint8_t, 0x2000003e, 0, 1, 4); STORE_BY_BITMASK(uint8_t, 0x2000003e, 0, 5, 3); memcpy((void*)0x2000003f, "\x8c\xda\x8b", 3); *(uint8_t*)0x20000042 = 0; memcpy((void*)0x20000043, "\x1b\xc6\x01", 3); *(uint32_t*)0x20000180 = 0; *(uint32_t*)0x20000184 = 0; *(uint32_t*)0x20000188 = 0; *(uint32_t*)0x2000018c = 0; *(uint32_t*)0x20000190 = 0; *(uint32_t*)0x20000194 = 0; struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x0, 16); csum_inet_update(&csum_1, (const uint8_t*)0x0, 16); uint32_t csum_1_chunk_2 = 0x10000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x21000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x0, 16); *(uint16_t*)0x2000003c = csum_inet_digest(&csum_1); syscall(__NR_ioctl, -1, 0x8912, 0x400200); syscall(__NR_socketpair, 1, 3, 0, 0x20000240); syscall(__NR_ioctl, -1, 0x8912, 0x400200); *(uint32_t*)0x20001000 = 0x10000; *(uint32_t*)0x20001004 = 4; *(uint32_t*)0x20001008 = 0x100; *(uint32_t*)0x2000100c = 0x400; syscall(__NR_setsockopt, -1, 0x84, 0, 0x20001000, 6); syscall(__NR_socket, 0x11, 0x80002, 0); return 0; }