// https://syzkaller.appspot.com/bug?id=570735f6f6ee6f1145a7ee95695227ff09804a3a // 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); } } #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_socket #define __NR_socket 359 #endif #ifndef __NR_ioctl #define __NR_ioctl 54 #endif #ifndef __NR_setsockopt #define __NR_setsockopt 366 #endif #ifndef __NR_bind #define __NR_bind 361 #endif #ifndef __NR_fcntl #define __NR_fcntl 55 #endif #ifndef __NR_dup2 #define __NR_dup2 63 #endif #ifndef __NR_write #define __NR_write 4 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 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*)0x20641ff3, "/dev/net/tun", 13); r[1] = syz_open_dev(0x20641ff3, 0, 0); r[2] = syscall(__NR_fcntl, r[1], 0, r[1]); r[3] = syscall(__NR_socket, 0x11, 0x80003, 8); *(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; *(uint32_t*)0x20927ff0 = 0x20c15000; *(uint32_t*)0x20c15000 = 0; *(uint32_t*)0x20c15004 = 0; *(uint16_t*)0x20c15008 = 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*)0x2086d000 = 0x73; *(uint8_t*)0x2086d001 = 0x79; *(uint8_t*)0x2086d002 = 0x7a; *(uint8_t*)0x2086d003 = 0x30; *(uint8_t*)0x2086d004 = 0; *(uint32_t*)0x2086d010 = 0; *(uint8_t*)0x2086d014 = 0; *(uint8_t*)0x2086d015 = 0; *(uint8_t*)0x2086d016 = 0; *(uint8_t*)0x2086d017 = 0; *(uint8_t*)0x2086d018 = 0; *(uint8_t*)0x2086d019 = 0; *(uint8_t*)0x2086d01a = 0; *(uint8_t*)0x2086d01b = 0; *(uint8_t*)0x2086d01c = 0; *(uint8_t*)0x2086d01d = 0; *(uint8_t*)0x2086d01e = 0; *(uint8_t*)0x2086d01f = 0; *(uint8_t*)0x2086d020 = 0; *(uint8_t*)0x2086d021 = 0; *(uint8_t*)0x2086d022 = 0; *(uint8_t*)0x2086d023 = 0; *(uint8_t*)0x2086d024 = 0; *(uint8_t*)0x2086d025 = 0; *(uint8_t*)0x2086d026 = 0; *(uint8_t*)0x2086d027 = 0; if (syscall(__NR_ioctl, r[3], 0x8933, 0x2086d000) != -1) r[4] = *(uint32_t*)0x2086d010; *(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 = 0; *(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*)0x20fecf2b = 0; *(uint8_t*)0x20fecf2c = 1; *(uint16_t*)0x20fecf2d = 0; *(uint16_t*)0x20fecf2f = 8; *(uint16_t*)0x20fecf31 = 0; *(uint16_t*)0x20fecf33 = 0; STORE_BY_BITMASK(uint8_t, 0x20fecf35, 5, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20fecf35, 4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x20fecf36, 0, 0, 2); STORE_BY_BITMASK(uint8_t, 0x20fecf36, 0, 2, 6); *(uint16_t*)0x20fecf37 = htobe16(0xc4); *(uint16_t*)0x20fecf39 = htobe16(0x64); *(uint16_t*)0x20fecf3b = htobe16(0); *(uint8_t*)0x20fecf3d = 0; *(uint8_t*)0x20fecf3e = 0x29; *(uint16_t*)0x20fecf3f = 0; *(uint32_t*)0x20fecf41 = htobe32(0xe0000001); *(uint8_t*)0x20fecf45 = 0xac; *(uint8_t*)0x20fecf46 = 0x14; *(uint8_t*)0x20fecf47 = 0; *(uint8_t*)0x20fecf48 = 0xaa; *(uint8_t*)0x20fecf49 = 5; *(uint8_t*)0x20fecf4a = 1; *(uint16_t*)0x20fecf4b = 0; *(uint32_t*)0x20fecf4d = htobe32(0x7f000001); STORE_BY_BITMASK(uint8_t, 0x20fecf51, 0x2a, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20fecf51, 4, 4, 4); STORE_BY_BITMASK(uint8_t, 0x20fecf52, 3, 0, 2); STORE_BY_BITMASK(uint8_t, 0x20fecf52, 0x43, 2, 6); *(uint16_t*)0x20fecf53 = htobe16(1); *(uint16_t*)0x20fecf55 = htobe16(0x65); *(uint16_t*)0x20fecf57 = htobe16(6); *(uint8_t*)0x20fecf59 = 9; *(uint8_t*)0x20fecf5a = 0x89; *(uint16_t*)0x20fecf5b = htobe16(0); *(uint8_t*)0x20fecf5d = 0xac; *(uint8_t*)0x20fecf5e = 0x14; *(uint8_t*)0x20fecf5f = 0; *(uint8_t*)0x20fecf60 = 0xaa; *(uint32_t*)0x20fecf61 = htobe32(0x7f000001); *(uint8_t*)0x20fecf65 = 0x44; *(uint8_t*)0x20fecf66 = 0x10; *(uint8_t*)0x20fecf67 = 0x4c; STORE_BY_BITMASK(uint8_t, 0x20fecf68, 3, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20fecf68, 1, 4, 4); *(uint32_t*)0x20fecf69 = htobe32(1); *(uint32_t*)0x20fecf6d = htobe32(9); *(uint32_t*)0x20fecf71 = htobe32(0xea41); *(uint8_t*)0x20fecf75 = 1; *(uint8_t*)0x20fecf76 = 0x44; *(uint8_t*)0x20fecf77 = 0x44; *(uint8_t*)0x20fecf78 = 8; STORE_BY_BITMASK(uint8_t, 0x20fecf79, 0, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20fecf79, -1, 4, 4); *(uint32_t*)0x20fecf7a = htobe32(0x7f000001); *(uint32_t*)0x20fecf7e = htobe32(3); *(uint32_t*)0x20fecf82 = htobe32(0x7f000001); *(uint32_t*)0x20fecf86 = htobe32(9); *(uint32_t*)0x20fecf8a = htobe32(0xe0000002); *(uint32_t*)0x20fecf8e = htobe32(3); *(uint32_t*)0x20fecf92 = htobe32(0x7e4); *(uint32_t*)0x20fecf96 = htobe32(0xe0000001); *(uint32_t*)0x20fecf9a = htobe32(8); *(uint32_t*)0x20fecf9e = htobe32(0); *(uint32_t*)0x20fecfa2 = htobe32(0xbe400000); *(uint32_t*)0x20fecfa6 = htobe32(0); *(uint32_t*)0x20fecfaa = htobe32(3); *(uint32_t*)0x20fecfae = htobe32(6); *(uint8_t*)0x20fecfb2 = 0xac; *(uint8_t*)0x20fecfb3 = 0x14; *(uint8_t*)0x20fecfb4 = 0; *(uint8_t*)0x20fecfb5 = 0xbb; *(uint32_t*)0x20fecfb6 = htobe32(6); *(uint8_t*)0x20fecfba = 0x89; *(uint8_t*)0x20fecfbb = 7; *(uint8_t*)0x20fecfbc = 0x81; *(uint32_t*)0x20fecfbd = htobe32(4); *(uint8_t*)0x20fecfc1 = 7; *(uint8_t*)0x20fecfc2 = 0x13; *(uint8_t*)0x20fecfc3 = 0xe1; *(uint32_t*)0x20fecfc4 = htobe32(0); *(uint32_t*)0x20fecfc8 = htobe32(0xe0000002); *(uint32_t*)0x20fecfcc = htobe32(0x3f); *(uint32_t*)0x20fecfd0 = htobe32(0); *(uint8_t*)0x20fecfd4 = 0x44; *(uint8_t*)0x20fecfd5 = 0x1c; *(uint8_t*)0x20fecfd6 = 0; STORE_BY_BITMASK(uint8_t, 0x20fecfd7, 3, 0, 4); STORE_BY_BITMASK(uint8_t, 0x20fecfd7, 7, 4, 4); *(uint32_t*)0x20fecfd8 = htobe32(0xe0000001); *(uint32_t*)0x20fecfdc = htobe32(0x20); *(uint32_t*)0x20fecfe0 = htobe32(0xe0000002); *(uint32_t*)0x20fecfe4 = htobe32(1); *(uint32_t*)0x20fecfe8 = htobe32(-1); *(uint32_t*)0x20fecfec = htobe32(8); *(uint8_t*)0x20fecff0 = 1; *(uint8_t*)0x20fecff1 = 0x94; *(uint8_t*)0x20fecff2 = 6; *(uint32_t*)0x20fecff3 = htobe32(0x8000); struct csum_inet csum_1; csum_inet_init(&csum_1); csum_inet_update(&csum_1, (const uint8_t*)0x20fecf49, 176); *(uint16_t*)0x20fecf4b = csum_inet_digest(&csum_1); struct csum_inet csum_2; csum_inet_init(&csum_2); csum_inet_update(&csum_2, (const uint8_t*)0x20fecf35, 20); *(uint16_t*)0x20fecf3f = csum_inet_digest(&csum_2); syscall(__NR_write, r[2], 0x20fecf2b, 0xce); } int main() { loop(); return 0; }