// https://syzkaller.appspot.com/bug?id=b99a32e971368f716992e75d20025d2f2b1dd8bc // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_sendmsg #define __NR_sendmsg 370 #endif #ifndef __NR_socket #define __NR_socket 359 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = syscall(__NR_socket, 0x10, 3, 0xc); if (res != -1) r[0] = res; *(uint32_t*)0x20003ac0 = 0; *(uint32_t*)0x20003ac4 = 0; *(uint32_t*)0x20003ac8 = 0x20003a80; *(uint32_t*)0x20003a80 = 0x20003940; *(uint32_t*)0x20003940 = 0x14; *(uint16_t*)0x20003944 = 0x10; *(uint16_t*)0x20003946 = 1; *(uint32_t*)0x20003948 = 0; *(uint32_t*)0x2000394c = 0; *(uint8_t*)0x20003950 = 0; *(uint8_t*)0x20003951 = 0; *(uint16_t*)0x20003952 = htobe16(0xa); *(uint32_t*)0x20003954 = 0xe0; *(uint8_t*)0x20003958 = 0x18; *(uint8_t*)0x20003959 = 0xa; *(uint16_t*)0x2000395a = 0x101; *(uint32_t*)0x2000395c = 0; *(uint32_t*)0x20003960 = 0; *(uint8_t*)0x20003964 = 1; *(uint8_t*)0x20003965 = 0; *(uint16_t*)0x20003966 = htobe16(0); *(uint16_t*)0x20003968 = 8; STORE_BY_BITMASK(uint16_t, , 0x2000396a, 7, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000396b, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000396b, 0, 7, 1); *(uint32_t*)0x2000396c = htobe32(3); *(uint16_t*)0x20003970 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x20003972, 5, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003973, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003973, 0, 7, 1); *(uint64_t*)0x20003974 = htobe64(1); *(uint16_t*)0x2000397c = 8; STORE_BY_BITMASK(uint16_t, , 0x2000397e, 7, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000397f, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000397f, 0, 7, 1); *(uint32_t*)0x20003980 = htobe32(1); *(uint16_t*)0x20003984 = 0xa4; STORE_BY_BITMASK(uint16_t, , 0x20003986, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003987, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003987, 1, 7, 1); *(uint16_t*)0x20003988 = 8; STORE_BY_BITMASK(uint16_t, , 0x2000398a, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000398b, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000398b, 0, 7, 1); *(uint32_t*)0x2000398c = htobe32(0); *(uint16_t*)0x20003990 = 0x68; STORE_BY_BITMASK(uint16_t, , 0x20003992, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003993, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003993, 1, 7, 1); *(uint16_t*)0x20003994 = 0x14; *(uint16_t*)0x20003996 = 1; memcpy((void*)0x20003998, "veth0_vlan\000\000\000\000\000\000", 16); *(uint16_t*)0x200039a8 = 0x14; *(uint16_t*)0x200039aa = 1; memcpy((void*)0x200039ac, "bond0\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint16_t*)0x200039bc = 0x14; *(uint16_t*)0x200039be = 1; memcpy((void*)0x200039c0, "ip6gretap0\000\000\000\000\000\000", 16); *(uint16_t*)0x200039d0 = 0x14; *(uint16_t*)0x200039d2 = 1; memcpy((void*)0x200039d4, "gretap0\000\000\000\000\000\000\000\000\000", 16); *(uint16_t*)0x200039e4 = 0x14; *(uint16_t*)0x200039e6 = 1; memcpy((void*)0x200039e8, "lo\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint16_t*)0x200039f8 = 8; STORE_BY_BITMASK(uint16_t, , 0x200039fa, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200039fb, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200039fb, 0, 7, 1); *(uint32_t*)0x200039fc = htobe32(5); *(uint16_t*)0x20003a00 = 8; STORE_BY_BITMASK(uint16_t, , 0x20003a02, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003a03, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003a03, 0, 7, 1); *(uint32_t*)0x20003a04 = htobe32(0); *(uint16_t*)0x20003a08 = 8; STORE_BY_BITMASK(uint16_t, , 0x20003a0a, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003a0b, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003a0b, 0, 7, 1); *(uint32_t*)0x20003a0c = htobe32(0); *(uint16_t*)0x20003a10 = 8; STORE_BY_BITMASK(uint16_t, , 0x20003a12, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003a13, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003a13, 0, 7, 1); *(uint32_t*)0x20003a14 = htobe32(0); *(uint16_t*)0x20003a18 = 8; STORE_BY_BITMASK(uint16_t, , 0x20003a1a, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003a1b, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003a1b, 0, 7, 1); *(uint32_t*)0x20003a1c = htobe32(0); *(uint16_t*)0x20003a20 = 8; STORE_BY_BITMASK(uint16_t, , 0x20003a22, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20003a23, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20003a23, 0, 7, 1); *(uint32_t*)0x20003a24 = htobe32(4); *(uint16_t*)0x20003a28 = 9; *(uint16_t*)0x20003a2a = 1; memcpy((void*)0x20003a2c, "syz0\000", 5); *(uint32_t*)0x20003a34 = 0x2c; *(uint8_t*)0x20003a38 = 2; *(uint8_t*)0x20003a39 = 0xa; *(uint16_t*)0x20003a3a = 0x101; *(uint32_t*)0x20003a3c = 0; *(uint32_t*)0x20003a40 = 0; *(uint8_t*)0x20003a44 = 0; *(uint8_t*)0x20003a45 = 0; *(uint16_t*)0x20003a46 = htobe16(1); *(uint16_t*)0x20003a48 = 9; *(uint16_t*)0x20003a4a = 1; memcpy((void*)0x20003a4c, "syz0\000", 5); *(uint16_t*)0x20003a54 = 9; *(uint16_t*)0x20003a56 = 1; memcpy((void*)0x20003a58, "syz0\000", 5); *(uint32_t*)0x20003a60 = 0x14; *(uint16_t*)0x20003a64 = 0x11; *(uint16_t*)0x20003a66 = 1; *(uint32_t*)0x20003a68 = 0; *(uint32_t*)0x20003a6c = 0; *(uint8_t*)0x20003a70 = 0; *(uint8_t*)0x20003a71 = 0; *(uint16_t*)0x20003a72 = htobe16(0xa); *(uint32_t*)0x20003a84 = 0x134; *(uint32_t*)0x20003acc = 1; *(uint32_t*)0x20003ad0 = 0; *(uint32_t*)0x20003ad4 = 0; *(uint32_t*)0x20003ad8 = 0x4000800; syscall(__NR_sendmsg, (intptr_t)r[0], 0x20003ac0, 0x42); *(uint32_t*)0x20003e00 = 0; *(uint32_t*)0x20003e04 = 0; *(uint32_t*)0x20003e08 = 0x20003dc0; *(uint32_t*)0x20003dc0 = 0x20000200; *(uint32_t*)0x20000200 = 0x14; *(uint16_t*)0x20000204 = 0x10; *(uint16_t*)0x20000206 = 1; *(uint32_t*)0x20000208 = 0; *(uint32_t*)0x2000020c = 0; *(uint8_t*)0x20000210 = 0; *(uint8_t*)0x20000211 = 0; *(uint16_t*)0x20000212 = htobe16(0xa); *(uint32_t*)0x20000214 = 0x20; *(uint8_t*)0x20000218 = 0; *(uint8_t*)0x20000219 = 0xa; *(uint16_t*)0x2000021a = 0x1405; *(uint32_t*)0x2000021c = 0; *(uint32_t*)0x20000220 = 0; *(uint8_t*)0x20000224 = 1; *(uint8_t*)0x20000225 = 0; *(uint16_t*)0x20000226 = htobe16(0); *(uint16_t*)0x20000228 = 9; *(uint16_t*)0x2000022a = 1; memcpy((void*)0x2000022c, "syz0\000", 5); *(uint32_t*)0x20000234 = 0x58; *(uint8_t*)0x20000238 = 0x16; *(uint8_t*)0x20000239 = 0xa; *(uint16_t*)0x2000023a = 1; *(uint32_t*)0x2000023c = 0; *(uint32_t*)0x20000240 = 0; *(uint8_t*)0x20000244 = 1; *(uint8_t*)0x20000245 = 0; *(uint16_t*)0x20000246 = htobe16(0); *(uint16_t*)0x20000248 = 9; *(uint16_t*)0x2000024a = 1; memcpy((void*)0x2000024c, "syz0\000", 5); *(uint16_t*)0x20000254 = 9; *(uint16_t*)0x20000256 = 2; memcpy((void*)0x20000258, "syz2\000", 5); *(uint16_t*)0x20000260 = 0x2c; STORE_BY_BITMASK(uint16_t, , 0x20000262, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000263, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000263, 1, 7, 1); *(uint16_t*)0x20000264 = 0x18; STORE_BY_BITMASK(uint16_t, , 0x20000266, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000267, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000267, 1, 7, 1); *(uint16_t*)0x20000268 = 0x14; *(uint16_t*)0x2000026a = 1; memcpy((void*)0x2000026c, "lo\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint16_t*)0x2000027c = 8; STORE_BY_BITMASK(uint16_t, , 0x2000027e, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000027f, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000027f, 0, 7, 1); *(uint32_t*)0x20000280 = htobe32(0); *(uint16_t*)0x20000284 = 8; STORE_BY_BITMASK(uint16_t, , 0x20000286, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000287, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000287, 0, 7, 1); *(uint32_t*)0x20000288 = htobe32(0); *(uint32_t*)0x2000028c = 0x14; *(uint16_t*)0x20000290 = 0x11; *(uint16_t*)0x20000292 = 1; *(uint32_t*)0x20000294 = 0; *(uint32_t*)0x20000298 = 0; *(uint8_t*)0x2000029c = 0; *(uint8_t*)0x2000029d = 0; *(uint16_t*)0x2000029e = htobe16(0xa); *(uint32_t*)0x20003dc4 = 0xa0; *(uint32_t*)0x20003e0c = 1; *(uint32_t*)0x20003e10 = 0; *(uint32_t*)0x20003e14 = 0; *(uint32_t*)0x20003e18 = 0; syscall(__NR_sendmsg, (intptr_t)r[0], 0x20003e00, 0); } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }