// 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*)0x20000000 = 0xa; *(uint16_t*)0x20000002 = htobe16(0x4e20); *(uint32_t*)0x20000004 = 0x1000; *(uint8_t*)0x20000008 = 0; *(uint8_t*)0x20000009 = 0; *(uint8_t*)0x2000000a = 0; *(uint8_t*)0x2000000b = 0; *(uint8_t*)0x2000000c = 0; *(uint8_t*)0x2000000d = 0; *(uint8_t*)0x2000000e = 0; *(uint8_t*)0x2000000f = 0; *(uint8_t*)0x20000010 = 0; *(uint8_t*)0x20000011 = 0; *(uint8_t*)0x20000012 = -1; *(uint8_t*)0x20000013 = -1; *(uint32_t*)0x20000014 = htobe32(0x7f000001); *(uint32_t*)0x20000018 = 1; syscall(__NR_connect, r[0], 0x20000000, 0x1c); *(uint16_t*)0x2064eff0 = 4; *(uint16_t*)0x2064eff2 = htobe16(0); *(uint32_t*)0x2064eff4 = htobe32(0x800); memcpy((void*)0x2064eff8, "\x86\x46\x2e\xb9\x66\xdc", 6); *(uint8_t*)0x2064effe = 8; *(uint8_t*)0x2064efff = 0; syscall(__NR_sendto, r[1], 0x20de7000, 0, 0xc3fe68eda9554f8b, 0x2064eff0, 0x80); *(uint8_t*)0x2070aef1 = 1; *(uint8_t*)0x2070aef2 = 0x80; *(uint8_t*)0x2070aef3 = 0xc2; *(uint8_t*)0x2070aef4 = 0; *(uint8_t*)0x2070aef5 = 0; *(uint8_t*)0x2070aef6 = 0; *(uint8_t*)0x2070aef7 = 1; *(uint8_t*)0x2070aef8 = 0x80; *(uint8_t*)0x2070aef9 = 0xc2; *(uint8_t*)0x2070aefa = 0; *(uint8_t*)0x2070aefb = 0; *(uint8_t*)0x2070aefc = 0; *(uint16_t*)0x2070aefd = htobe16(0x800); STORE_BY_BITMASK(uint8_t, 0x2070aeff, 5, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2070aeff, 4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x2070af00, 0, 0, 2); STORE_BY_BITMASK(uint8_t, 0x2070af00, 0, 2, 6); *(uint16_t*)0x2070af01 = htobe16(0x1c); *(uint16_t*)0x2070af03 = htobe16(0); *(uint16_t*)0x2070af05 = htobe16(0); *(uint8_t*)0x2070af07 = 0; *(uint8_t*)0x2070af08 = 0x11; *(uint16_t*)0x2070af09 = 0; *(uint8_t*)0x2070af0b = 0xac; *(uint8_t*)0x2070af0c = 0x14; *(uint8_t*)0x2070af0d = -1; *(uint8_t*)0x2070af0e = 0xbb; *(uint32_t*)0x2070af0f = htobe32(-1); *(uint16_t*)0x2070af13 = htobe16(0); *(uint16_t*)0x2070af15 = htobe16(0x4e21); *(uint16_t*)0x2070af17 = htobe16(8); *(uint16_t*)0x2070af19 = 0; struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x2070af0b, 4); csum_inet_update(&csum_1, (const uint8_t*)0x2070af0f, 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*)0x2070af13, 8); *(uint16_t*)0x2070af19 = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x2070aeff, 20); *(uint16_t*)0x2070af09 = csum_inet_digest(&csum_2); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }