// https://syzkaller.appspot.com/bug?id=4f5b71612ca24f1c814f1413a8022656c4cae691 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #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; } static uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf)); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } long r[5]; void loop() { memset(r, -1, sizeof(r)); syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); r[0] = syscall(__NR_socket, 2, 1, 0); memcpy((void*)0x20c55000, "/dev/net/tun", 13); r[1] = syz_open_dev(0x20c55000, 0, 0); r[2] = syscall(__NR_fcntl, r[1], 0, r[1]); r[3] = syscall(__NR_socket, 0x2000000011, 0x8000000080003, 6); *(uint8_t*)0x20927fd8 = 0x73; *(uint8_t*)0x20927fd9 = 0x79; *(uint8_t*)0x20927fda = 0x7a; *(uint8_t*)0x20927fdb = 0x30; *(uint8_t*)0x20927fdc = 0; *(uint32_t*)0x20927fe8 = 5; *(uint32_t*)0x20927fec = 0; *(uint64_t*)0x20927ff0 = 0x201a3ff4; *(uint32_t*)0x201a3ff4 = 0; *(uint32_t*)0x201a3ff8 = 0; *(uint16_t*)0x201a3ffc = 0; syscall(__NR_ioctl, r[1], 0x400454ca, 0x20927fd8); *(uint8_t*)0x2062ffe0 = 0x73; *(uint8_t*)0x2062ffe1 = 0x79; *(uint8_t*)0x2062ffe2 = 0x7a; *(uint8_t*)0x2062ffe3 = 0x30; *(uint8_t*)0x2062ffe4 = 0; *(uint16_t*)0x2062fff0 = 0x301; syscall(__NR_ioctl, r[0], 0x8914, 0x2062ffe0); *(uint32_t*)0x20113000 = 0x1000; syscall(__NR_setsockopt, r[3], 0x107, 0xf, 0x20113000, 4); *(uint8_t*)0x20b13000 = 0x73; *(uint8_t*)0x20b13001 = 0x79; *(uint8_t*)0x20b13002 = 0x7a; *(uint8_t*)0x20b13003 = 0x30; *(uint8_t*)0x20b13004 = 0; *(uint32_t*)0x20b13010 = 0; *(uint8_t*)0x20b13014 = 0; *(uint8_t*)0x20b13015 = 0; *(uint8_t*)0x20b13016 = 0; *(uint8_t*)0x20b13017 = 0; *(uint8_t*)0x20b13018 = 0; *(uint8_t*)0x20b13019 = 0; *(uint8_t*)0x20b1301a = 0; *(uint8_t*)0x20b1301b = 0; *(uint8_t*)0x20b1301c = 0; *(uint8_t*)0x20b1301d = 0; *(uint8_t*)0x20b1301e = 0; *(uint8_t*)0x20b1301f = 0; *(uint8_t*)0x20b13020 = 0; *(uint8_t*)0x20b13021 = 0; *(uint8_t*)0x20b13022 = 0; *(uint8_t*)0x20b13023 = 0; *(uint8_t*)0x20b13024 = 0; *(uint8_t*)0x20b13025 = 0; *(uint8_t*)0x20b13026 = 0; *(uint8_t*)0x20b13027 = 0; if (syscall(__NR_ioctl, r[3], 0x8933, 0x20b13000) != -1) r[4] = *(uint32_t*)0x20b13010; *(uint16_t*)0x20c85000 = 0x11; *(uint16_t*)0x20c85002 = htobe16(0); *(uint32_t*)0x20c85004 = r[4]; *(uint16_t*)0x20c85008 = 1; *(uint8_t*)0x20c8500a = 0; *(uint8_t*)0x20c8500b = 6; *(uint8_t*)0x20c8500c = 0xaa; *(uint8_t*)0x20c8500d = 0xaa; *(uint8_t*)0x20c8500e = 0xaa; *(uint8_t*)0x20c8500f = 0xaa; *(uint8_t*)0x20c85010 = 0xaa; *(uint8_t*)0x20c85011 = 0; *(uint8_t*)0x20c85012 = 0; *(uint8_t*)0x20c85013 = 0; syscall(__NR_bind, r[3], 0x20c85000, 0x14); syscall(__NR_dup2, r[3], r[2]); *(uint8_t*)0x204f0000 = 0; *(uint8_t*)0x204f0001 = 4; *(uint16_t*)0x204f0002 = 0; *(uint16_t*)0x204f0004 = 3; *(uint16_t*)0x204f0006 = 0; *(uint16_t*)0x204f0008 = 0; STORE_BY_BITMASK(uint8_t, 0x204f000a, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x204f000a, 6, 4, 4); memcpy((void*)0x204f000b, "\x35\x6d\x06", 3); *(uint16_t*)0x204f000e = htobe16(0x10); *(uint8_t*)0x204f0010 = 0; *(uint8_t*)0x204f0011 = 0; *(uint64_t*)0x204f0012 = htobe64(0); *(uint64_t*)0x204f001a = htobe64(1); *(uint8_t*)0x204f0022 = 0xfe; *(uint8_t*)0x204f0023 = 0x80; *(uint8_t*)0x204f0024 = 0; *(uint8_t*)0x204f0025 = 0; *(uint8_t*)0x204f0026 = 0; *(uint8_t*)0x204f0027 = 0; *(uint8_t*)0x204f0028 = 0; *(uint8_t*)0x204f0029 = 0; *(uint8_t*)0x204f002a = 0; *(uint8_t*)0x204f002b = 0; *(uint8_t*)0x204f002c = 0; *(uint8_t*)0x204f002d = 0; *(uint8_t*)0x204f002e = 0; *(uint8_t*)0x204f002f = 0; *(uint8_t*)0x204f0030 = 0; *(uint8_t*)0x204f0031 = 0xaa; *(uint16_t*)0x204f0032 = htobe16(0x4e20); *(uint16_t*)0x204f0034 = htobe16(0x4e20); *(uint8_t*)0x204f0036 = 4; STORE_BY_BITMASK(uint8_t, 0x204f0037, 1, 0, 4); STORE_BY_BITMASK(uint8_t, 0x204f0037, 0, 4, 4); *(uint16_t*)0x204f0038 = 0; STORE_BY_BITMASK(uint8_t, 0x204f003a, 0, 0, 1); STORE_BY_BITMASK(uint8_t, 0x204f003a, 0, 1, 4); STORE_BY_BITMASK(uint8_t, 0x204f003a, 0, 5, 3); memcpy((void*)0x204f003b, "\x80\x00\x5e", 3); *(uint8_t*)0x204f003e = 0; memcpy((void*)0x204f003f, "\xaa\x90\xf7", 3); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x204f0012, 16); csum_inet_update(&csum_1, (const uint8_t*)0x204f0022, 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*)0x204f0032, 16); *(uint16_t*)0x204f0038 = csum_inet_digest(&csum_1); syscall(__NR_write, r[2], 0x204f0000, 0x42); } int main() { loop(); return 0; }