// https://syzkaller.appspot.com/bug?id=a5c74eee04149854dd8b59fdfc0529a60be422a7 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #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, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); r[0] = syscall(__NR_socket, 0x2ul, 0x1ul, 0x0ul); memcpy((void*)0x20c55000, "/dev/net/tun", 13); r[1] = syz_open_dev(0x20c55000ul, 0x0ul, 0x0ul); r[2] = syscall(__NR_fcntl, r[1], 0x0ul, r[1]); r[3] = syscall(__NR_socket, 0x2000000011ul, 0x8000000080003ul, 0x6ul); *(uint8_t*)0x20927fd8 = (uint8_t)0x73; *(uint8_t*)0x20927fd9 = (uint8_t)0x79; *(uint8_t*)0x20927fda = (uint8_t)0x7a; *(uint8_t*)0x20927fdb = (uint8_t)0x30; *(uint8_t*)0x20927fdc = (uint8_t)0x0; *(uint32_t*)0x20927fe8 = (uint32_t)0x5; *(uint32_t*)0x20927fec = (uint32_t)0x0; *(uint64_t*)0x20927ff0 = (uint64_t)0x201a3ff4; *(uint32_t*)0x201a3ff4 = (uint32_t)0x0; *(uint32_t*)0x201a3ff8 = (uint32_t)0x0; *(uint16_t*)0x201a3ffc = (uint16_t)0x0; syscall(__NR_ioctl, r[1], 0x400454caul, 0x20927fd8ul); *(uint8_t*)0x2062ffe0 = (uint8_t)0x73; *(uint8_t*)0x2062ffe1 = (uint8_t)0x79; *(uint8_t*)0x2062ffe2 = (uint8_t)0x7a; *(uint8_t*)0x2062ffe3 = (uint8_t)0x30; *(uint8_t*)0x2062ffe4 = (uint8_t)0x0; *(uint16_t*)0x2062fff0 = (uint16_t)0x20301; syscall(__NR_ioctl, r[0], 0x8914ul, 0x2062ffe0ul); *(uint32_t*)0x20113000 = (uint32_t)0x1000; syscall(__NR_setsockopt, r[3], 0x107ul, 0xful, 0x20113000ul, 0x4ul); *(uint8_t*)0x20b13000 = (uint8_t)0x73; *(uint8_t*)0x20b13001 = (uint8_t)0x79; *(uint8_t*)0x20b13002 = (uint8_t)0x7a; *(uint8_t*)0x20b13003 = (uint8_t)0x30; *(uint8_t*)0x20b13004 = (uint8_t)0x0; *(uint32_t*)0x20b13010 = (uint32_t)0x0; *(uint8_t*)0x20b13014 = (uint8_t)0x0; *(uint8_t*)0x20b13015 = (uint8_t)0x0; *(uint8_t*)0x20b13016 = (uint8_t)0x0; *(uint8_t*)0x20b13017 = (uint8_t)0x0; *(uint8_t*)0x20b13018 = (uint8_t)0x0; *(uint8_t*)0x20b13019 = (uint8_t)0x0; *(uint8_t*)0x20b1301a = (uint8_t)0x0; *(uint8_t*)0x20b1301b = (uint8_t)0x0; *(uint8_t*)0x20b1301c = (uint8_t)0x0; *(uint8_t*)0x20b1301d = (uint8_t)0x0; *(uint8_t*)0x20b1301e = (uint8_t)0x0; *(uint8_t*)0x20b1301f = (uint8_t)0x0; *(uint8_t*)0x20b13020 = (uint8_t)0x0; *(uint8_t*)0x20b13021 = (uint8_t)0x0; *(uint8_t*)0x20b13022 = (uint8_t)0x0; *(uint8_t*)0x20b13023 = (uint8_t)0x0; *(uint8_t*)0x20b13024 = (uint8_t)0x0; *(uint8_t*)0x20b13025 = (uint8_t)0x0; *(uint8_t*)0x20b13026 = (uint8_t)0x0; *(uint8_t*)0x20b13027 = (uint8_t)0x0; if (syscall(__NR_ioctl, r[3], 0x8933ul, 0x20b13000ul) != -1) { r[4] = *(uint32_t*)0x20b13010; } *(uint16_t*)0x20c85000 = (uint16_t)0x11; *(uint16_t*)0x20c85002 = (uint16_t)0x0; *(uint32_t*)0x20c85004 = r[4]; *(uint16_t*)0x20c85008 = (uint16_t)0x1; *(uint8_t*)0x20c8500a = (uint8_t)0x0; *(uint8_t*)0x20c8500b = (uint8_t)0x6; *(uint8_t*)0x20c8500c = (uint8_t)0xaa; *(uint8_t*)0x20c8500d = (uint8_t)0xaa; *(uint8_t*)0x20c8500e = (uint8_t)0xaa; *(uint8_t*)0x20c8500f = (uint8_t)0xaa; *(uint8_t*)0x20c85010 = (uint8_t)0xaa; *(uint8_t*)0x20c85011 = (uint8_t)0x0; *(uint8_t*)0x20c85012 = (uint8_t)0x0; *(uint8_t*)0x20c85013 = (uint8_t)0x0; syscall(__NR_bind, r[3], 0x20c85000ul, 0x14ul); syscall(__NR_dup2, r[3], r[2]); *(uint8_t*)0x204f0000 = (uint8_t)0x0; *(uint8_t*)0x204f0001 = (uint8_t)0x4; *(uint16_t*)0x204f0002 = (uint16_t)0x0; *(uint16_t*)0x204f0004 = (uint16_t)0x3; *(uint16_t*)0x204f0006 = (uint16_t)0x0; *(uint16_t*)0x204f0008 = (uint16_t)0x0; STORE_BY_BITMASK(uint8_t, 0x204f000a, 0x0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x204f000a, 0x6, 4, 4); memcpy((void*)0x204f000b, "\x35\x6d\x06", 3); *(uint16_t*)0x204f000e = (uint16_t)0x1000; *(uint8_t*)0x204f0010 = (uint8_t)0x0; *(uint8_t*)0x204f0011 = (uint8_t)0x0; *(uint64_t*)0x204f0012 = (uint64_t)0x0; *(uint64_t*)0x204f001a = (uint64_t)0x100000000000000; *(uint8_t*)0x204f0022 = (uint8_t)0xfe; *(uint8_t*)0x204f0023 = (uint8_t)0x80; *(uint8_t*)0x204f0024 = (uint8_t)0x0; *(uint8_t*)0x204f0025 = (uint8_t)0x0; *(uint8_t*)0x204f0026 = (uint8_t)0x0; *(uint8_t*)0x204f0027 = (uint8_t)0x0; *(uint8_t*)0x204f0028 = (uint8_t)0x0; *(uint8_t*)0x204f0029 = (uint8_t)0x0; *(uint8_t*)0x204f002a = (uint8_t)0x0; *(uint8_t*)0x204f002b = (uint8_t)0x0; *(uint8_t*)0x204f002c = (uint8_t)0x0; *(uint8_t*)0x204f002d = (uint8_t)0x0; *(uint8_t*)0x204f002e = (uint8_t)0x0; *(uint8_t*)0x204f002f = (uint8_t)0x0; *(uint8_t*)0x204f0030 = (uint8_t)0x0; *(uint8_t*)0x204f0031 = (uint8_t)0xaa; *(uint16_t*)0x204f0032 = (uint16_t)0x204e; *(uint16_t*)0x204f0034 = (uint16_t)0x204e; *(uint8_t*)0x204f0036 = (uint8_t)0x4; STORE_BY_BITMASK(uint8_t, 0x204f0037, 0x1, 0, 4); STORE_BY_BITMASK(uint8_t, 0x204f0037, 0x0, 4, 4); *(uint16_t*)0x204f0038 = (uint16_t)0x0; STORE_BY_BITMASK(uint8_t, 0x204f003a, 0x0, 0, 1); STORE_BY_BITMASK(uint8_t, 0x204f003a, 0x0, 1, 4); STORE_BY_BITMASK(uint8_t, 0x204f003a, 0x0, 5, 3); memcpy((void*)0x204f003b, "\x80\x00\x5e", 3); *(uint8_t*)0x204f003e = (uint8_t)0x0; 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], 0x204f0000ul, 0x42ul); } int main() { loop(); return 0; }