// 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*)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; *(uint32_t*)0x200000d4 = htobe32(0); *(uint32_t*)0x200000d8 = 3; syscall(__NR_connect, r[0], 0x200000c0, 0x1c); syscall(__NR_sendto, r[1], 0x20de7000, 0, 0xc3fe68eda9554f8b, 0x20000000, 0); *(uint8_t*)0x20000100 = 0xaa; *(uint8_t*)0x20000101 = 0xaa; *(uint8_t*)0x20000102 = 0xaa; *(uint8_t*)0x20000103 = 0xaa; *(uint8_t*)0x20000104 = 0xaa; *(uint8_t*)0x20000105 = 0xaa; *(uint8_t*)0x20000106 = -1; *(uint8_t*)0x20000107 = -1; *(uint8_t*)0x20000108 = -1; *(uint8_t*)0x20000109 = -1; *(uint8_t*)0x2000010a = -1; *(uint8_t*)0x2000010b = -1; *(uint16_t*)0x2000010c = htobe16(0x86dd); STORE_BY_BITMASK(uint8_t, 0x2000010e, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x2000010e, 6, 4, 4); memcpy((void*)0x2000010f, "\xd8\x65\x2b", 3); *(uint16_t*)0x20000112 = htobe16(0x14); *(uint8_t*)0x20000114 = 6; *(uint8_t*)0x20000115 = 0; *(uint8_t*)0x20000116 = 0xfe; *(uint8_t*)0x20000117 = 0x7e; *(uint8_t*)0x20000118 = 0; *(uint8_t*)0x20000119 = 0; *(uint8_t*)0x2000011a = 0; *(uint8_t*)0x2000011b = 0; *(uint8_t*)0x2000011c = 0; *(uint8_t*)0x2000011d = 0; *(uint8_t*)0x2000011e = 0; *(uint8_t*)0x2000011f = 0; *(uint8_t*)0x20000120 = 0; *(uint8_t*)0x20000121 = 0; *(uint8_t*)0x20000122 = 0; *(uint8_t*)0x20000123 = 0; *(uint8_t*)0x20000124 = 0; *(uint8_t*)0x20000125 = 0xaa; *(uint8_t*)0x20000126 = 0xfe; *(uint8_t*)0x20000127 = 0x80; *(uint8_t*)0x20000128 = 0; *(uint8_t*)0x20000129 = 0; *(uint8_t*)0x2000012a = 0; *(uint8_t*)0x2000012b = 0; *(uint8_t*)0x2000012c = 0; *(uint8_t*)0x2000012d = 0; *(uint8_t*)0x2000012e = 0; *(uint8_t*)0x2000012f = 0; *(uint8_t*)0x20000130 = 0; *(uint8_t*)0x20000131 = 0; *(uint8_t*)0x20000132 = 0; *(uint8_t*)0x20000133 = 0; *(uint8_t*)0x20000134 = 0; *(uint8_t*)0x20000135 = 0xaa; *(uint16_t*)0x20000136 = htobe16(0x4e20); *(uint16_t*)0x20000138 = htobe16(0x4e20); *(uint32_t*)0x2000013a = 0x41424344; *(uint32_t*)0x2000013e = 0x41424344; STORE_BY_BITMASK(uint8_t, 0x20000142, 0, 0, 1); STORE_BY_BITMASK(uint8_t, 0x20000142, 0, 1, 3); STORE_BY_BITMASK(uint8_t, 0x20000142, 5, 4, 4); *(uint8_t*)0x20000143 = 0; *(uint16_t*)0x20000144 = htobe16(0); *(uint16_t*)0x20000146 = 0; *(uint16_t*)0x20000148 = htobe16(0); *(uint32_t*)0x200002c0 = 0; *(uint32_t*)0x200002c4 = 0; *(uint32_t*)0x200002c8 = 0; *(uint32_t*)0x200002cc = 0; *(uint32_t*)0x200002d0 = 0; *(uint32_t*)0x200002d4 = 0; struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20000116, 16); csum_inet_update(&csum_1, (const uint8_t*)0x20000126, 16); uint32_t csum_1_chunk_2 = 0x14000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_2, 4); uint32_t csum_1_chunk_3 = 0x6000000; csum_inet_update(&csum_1, (const uint8_t*)&csum_1_chunk_3, 4); csum_inet_update(&csum_1, (const uint8_t*)0x20000136, 20); *(uint16_t*)0x20000146 = csum_inet_digest(&csum_1); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }