// https://syzkaller.appspot.com/bug?id=2c595167294aa449aaa72ecf3cac3357318b4ccb // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void loop() { long res; res = syscall(__NR_socket, 0xa, 2, 0); if (res != -1) r[0] = res; res = syscall(__NR_socket, 0x18, 1, 1); if (res != -1) r[1] = res; *(uint16_t*)0x205fafd2 = 0x18; *(uint32_t*)0x205fafd4 = 1; *(uint32_t*)0x205fafd8 = 0; *(uint32_t*)0x205fafdc = r[0]; *(uint16_t*)0x205fafe0 = 2; *(uint16_t*)0x205fafe2 = htobe16(0x4e21); *(uint8_t*)0x205fafe4 = 0xac; *(uint8_t*)0x205fafe5 = 0x14; *(uint8_t*)0x205fafe6 = 0; *(uint8_t*)0x205fafe7 = 0xbb; *(uint8_t*)0x205fafe8 = 0; *(uint8_t*)0x205fafe9 = 0; *(uint8_t*)0x205fafea = 0; *(uint8_t*)0x205fafeb = 0; *(uint8_t*)0x205fafec = 0; *(uint8_t*)0x205fafed = 0; *(uint8_t*)0x205fafee = 0; *(uint8_t*)0x205fafef = 0; *(uint32_t*)0x205faff0 = 4; *(uint32_t*)0x205faff4 = 0; *(uint32_t*)0x205faff8 = 2; *(uint32_t*)0x205faffc = 0; syscall(__NR_connect, r[1], 0x205fafd2, 0x2e); *(uint16_t*)0x200000c0 = 0xa; *(uint16_t*)0x200000c2 = htobe16(0x4e21); *(uint32_t*)0x200000c4 = 0x7fff; *(uint8_t*)0x200000c8 = 0; *(uint8_t*)0x200000c9 = 0; *(uint8_t*)0x200000ca = 0; *(uint8_t*)0x200000cb = 0; *(uint8_t*)0x200000cc = 0; *(uint8_t*)0x200000cd = 0; *(uint8_t*)0x200000ce = 0; *(uint8_t*)0x200000cf = 0; *(uint8_t*)0x200000d0 = 0; *(uint8_t*)0x200000d1 = 0; *(uint8_t*)0x200000d2 = -1; *(uint8_t*)0x200000d3 = -1; *(uint8_t*)0x200000d4 = 0xac; *(uint8_t*)0x200000d5 = 0x14; *(uint8_t*)0x200000d6 = 0x14; *(uint8_t*)0x200000d7 = 0xaa; *(uint32_t*)0x200000d8 = 3; syscall(__NR_connect, r[0], 0x200000c0, 0x1c); *(uint16_t*)0x200021c0 = 0x18; *(uint32_t*)0x200021c2 = 0; *(uint16_t*)0x200021c6 = 0; *(uint8_t*)0x200021c8 = 0; *(uint8_t*)0x200021c9 = 0; *(uint8_t*)0x200021ca = 0; *(uint8_t*)0x200021cb = 0; *(uint8_t*)0x200021cc = 0; *(uint8_t*)0x200021cd = 0; memcpy((void*)0x200021ce, "\x69\x66\x62\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16); syscall(__NR_sendto, r[1], 0x20001180, 0, 0x40001, 0x200021c0, 0x80); *(uint8_t*)0x20000040 = 0xaa; *(uint8_t*)0x20000041 = 0xaa; *(uint8_t*)0x20000042 = 0xaa; *(uint8_t*)0x20000043 = 0xaa; *(uint8_t*)0x20000044 = 0xaa; *(uint8_t*)0x20000045 = 0xaa; *(uint8_t*)0x20000046 = 0; *(uint8_t*)0x20000047 = 0; *(uint8_t*)0x20000048 = 0; *(uint8_t*)0x20000049 = 0; *(uint8_t*)0x2000004a = 0; *(uint8_t*)0x2000004b = 0; *(uint16_t*)0x2000004c = htobe16(0x800); STORE_BY_BITMASK(uint8_t, 0x2000004e, 6, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2000004e, 4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x2000004f, 0, 0, 2); STORE_BY_BITMASK(uint8_t, 0x2000004f, 0, 2, 6); *(uint16_t*)0x20000050 = htobe16(0x20); *(uint16_t*)0x20000052 = htobe16(0); *(uint16_t*)0x20000054 = htobe16(0); *(uint8_t*)0x20000056 = 0; *(uint8_t*)0x20000057 = 0; *(uint16_t*)0x20000058 = 0; *(uint8_t*)0x2000005a = 0xac; *(uint8_t*)0x2000005b = 0x14; *(uint8_t*)0x2000005c = 0x14; *(uint8_t*)0x2000005d = 0; *(uint8_t*)0x2000005e = 0xac; *(uint8_t*)0x2000005f = 0x14; *(uint8_t*)0x20000060 = 0x14; *(uint8_t*)0x20000061 = 0; *(uint8_t*)0x20000062 = 7; *(uint8_t*)0x20000063 = 3; *(uint8_t*)0x20000064 = 0; *(uint16_t*)0x20000066 = htobe16(0); *(uint16_t*)0x20000068 = htobe16(0); *(uint16_t*)0x2000006a = htobe16(8); *(uint16_t*)0x2000006c = 0; *(uint32_t*)0x20000100 = 0; *(uint32_t*)0x20000104 = 0; *(uint32_t*)0x20000108 = 0; *(uint32_t*)0x2000010c = 0; *(uint32_t*)0x20000110 = 0; *(uint32_t*)0x20000114 = 0; struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x2000005a, 4); csum_inet_update(&csum_1, (const uint8_t*)0x2000005e, 4); uint16_t csum_1_chunk_2 = 0x1100; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 2); uint16_t csum_1_chunk_3 = 0x800; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 2); csum_inet_update(&csum_1, (const uint8_t*)0x20000066, 8); *(uint16_t*)0x2000006c = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x2000004e, 24); *(uint16_t*)0x20000058 = csum_inet_digest(&csum_2); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }