// https://syzkaller.appspot.com/bug?id=be77af8f4170f3350bed40f1b060851541287f2f // 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*)0x200002c0 = 0xa; *(uint16_t*)0x200002c2 = htobe16(0x4e21); *(uint32_t*)0x200002c4 = 0x7fff; *(uint8_t*)0x200002c8 = 0; *(uint8_t*)0x200002c9 = 0; *(uint8_t*)0x200002ca = 0; *(uint8_t*)0x200002cb = 0; *(uint8_t*)0x200002cc = 0; *(uint8_t*)0x200002cd = 0; *(uint8_t*)0x200002ce = 0; *(uint8_t*)0x200002cf = 0; *(uint8_t*)0x200002d0 = 0; *(uint8_t*)0x200002d1 = 0; *(uint8_t*)0x200002d2 = -1; *(uint8_t*)0x200002d3 = -1; *(uint8_t*)0x200002d4 = 0xac; *(uint8_t*)0x200002d5 = 0x14; *(uint8_t*)0x200002d6 = 0x14; *(uint8_t*)0x200002d7 = 0xaa; *(uint32_t*)0x200002d8 = 3; syscall(__NR_connect, r[0], 0x200002c0, 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); memcpy((void*)0x20101000, "\xcd\x39\x0b\x08\x1b\xf2", 6); *(uint8_t*)0x20101006 = 1; *(uint8_t*)0x20101007 = 0x80; *(uint8_t*)0x20101008 = 0xc2; *(uint8_t*)0x20101009 = 0; *(uint8_t*)0x2010100a = 0; *(uint8_t*)0x2010100b = 3; *(uint16_t*)0x2010100c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, 0x2010100e, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2010100e, 6, 4, 4); memcpy((void*)0x2010100f, "\x02\x29\x0f", 3); *(uint16_t*)0x20101012 = htobe16(0x30); *(uint8_t*)0x20101014 = 0x3a; *(uint8_t*)0x20101015 = 0; *(uint8_t*)0x20101016 = 0; *(uint8_t*)0x20101017 = 0; *(uint8_t*)0x20101018 = 0; *(uint8_t*)0x20101019 = 0; *(uint8_t*)0x2010101a = 0; *(uint8_t*)0x2010101b = 0; *(uint8_t*)0x2010101c = 0; *(uint8_t*)0x2010101d = 0; *(uint8_t*)0x2010101e = 0; *(uint8_t*)0x2010101f = 0; *(uint8_t*)0x20101020 = -1; *(uint8_t*)0x20101021 = -1; *(uint32_t*)0x20101022 = htobe32(0); *(uint8_t*)0x20101026 = -1; *(uint8_t*)0x20101027 = 2; *(uint8_t*)0x20101028 = 0; *(uint8_t*)0x20101029 = 0; *(uint8_t*)0x2010102a = 0; *(uint8_t*)0x2010102b = 0; *(uint8_t*)0x2010102c = 0; *(uint8_t*)0x2010102d = 0; *(uint8_t*)0x2010102e = 0; *(uint8_t*)0x2010102f = 0; *(uint8_t*)0x20101030 = 0; *(uint8_t*)0x20101031 = 0; *(uint8_t*)0x20101032 = 0; *(uint8_t*)0x20101033 = 0; *(uint8_t*)0x20101034 = 0; *(uint8_t*)0x20101035 = 1; *(uint8_t*)0x20101036 = 2; *(uint8_t*)0x20101037 = 0; *(uint16_t*)0x20101038 = 0; *(uint32_t*)0x2010103a = htobe32(0); STORE_BY_BITMASK(uint8_t, 0x2010103e, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2010103e, 6, 4, 4); memcpy((void*)0x2010103f, "\x94\x33\xdf", 3); *(uint16_t*)0x20101042 = htobe16(0); *(uint8_t*)0x20101044 = 0x3a; *(uint8_t*)0x20101045 = 0; *(uint64_t*)0x20101046 = htobe64(0); *(uint64_t*)0x2010104e = htobe64(1); *(uint8_t*)0x20101056 = 0xfe; *(uint8_t*)0x20101057 = 0x80; *(uint8_t*)0x20101058 = 0; *(uint8_t*)0x20101059 = 0; *(uint8_t*)0x2010105a = 0; *(uint8_t*)0x2010105b = 0; *(uint8_t*)0x2010105c = 0; *(uint8_t*)0x2010105d = 0; *(uint8_t*)0x2010105e = 0; *(uint8_t*)0x2010105f = 0; *(uint8_t*)0x20101060 = 0; *(uint8_t*)0x20101061 = 0; *(uint8_t*)0x20101062 = 0; *(uint8_t*)0x20101063 = 0; *(uint8_t*)0x20101064 = 0; *(uint8_t*)0x20101065 = 0; struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20101016, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20101026, 16); uint32_t csum_1_chunk_2 = 0x30000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x3a000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20101036, 48); *(uint16_t*)0x20101038 = csum_inet_digest(&csum_1); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }