// https://syzkaller.appspot.com/bug?id=00fadf9a6326e13098672b601d57f644cae380e9 // 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); for (int 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 = 0; for (;; 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 < 5000) { continue; } kill_and_wait(pid, &status); break; } } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = syscall(__NR_socket, 0xaul, 0x80002ul, 0); if (res != -1) r[0] = res; memcpy((void*)0x20000ac0, "filter\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x20000ae0 = 0xe; *(uint32_t*)0x20000ae4 = 4; *(uint32_t*)0x20000ae8 = 0x400; *(uint32_t*)0x20000aec = 0xd0; *(uint32_t*)0x20000af0 = 0x1f8; *(uint32_t*)0x20000af4 = 0; *(uint32_t*)0x20000af8 = 0x1f8; *(uint32_t*)0x20000afc = 0xd0; *(uint32_t*)0x20000b00 = 0x2c0; *(uint32_t*)0x20000b04 = 0x330; *(uint32_t*)0x20000b08 = 0x330; *(uint32_t*)0x20000b0c = 0x330; *(uint32_t*)0x20000b10 = 0x2c0; *(uint32_t*)0x20000b14 = 4; *(uint64_t*)0x20000b18 = 0; memset((void*)0x20000b20, 0, 136); *(uint32_t*)0x20000ba8 = 0; *(uint16_t*)0x20000bac = 0xa8; *(uint16_t*)0x20000bae = 0x108; *(uint32_t*)0x20000bb0 = 0; *(uint64_t*)0x20000bb8 = 0; *(uint64_t*)0x20000bc0 = 0; *(uint16_t*)0x20000bc8 = 0x60; memcpy((void*)0x20000bca, "HMARK\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000", 29); *(uint8_t*)0x20000be7 = 0; *(uint32_t*)0x20000be8 = htobe32(-1); *(uint32_t*)0x20000bf8 = htobe32(0); *(uint32_t*)0x20000bfc = htobe32(0); *(uint32_t*)0x20000c00 = htobe32(0); *(uint32_t*)0x20000c04 = htobe32(0); *(uint16_t*)0x20000c08 = htobe16(0); *(uint16_t*)0x20000c0a = htobe16(0); *(uint16_t*)0x20000c0c = htobe16(0); *(uint16_t*)0x20000c0e = htobe16(0); *(uint32_t*)0x20000c10 = 0; *(uint16_t*)0x20000c14 = 0; *(uint32_t*)0x20000c18 = 0; *(uint32_t*)0x20000c1c = 4; *(uint32_t*)0x20000c20 = 0; *(uint8_t*)0x20000c28 = 0xfe; *(uint8_t*)0x20000c29 = 0x88; memset((void*)0x20000c2a, 0, 12); *(uint8_t*)0x20000c36 = 0; *(uint8_t*)0x20000c37 = 1; memset((void*)0x20000c38, 0, 10); memset((void*)0x20000c42, 255, 2); *(uint8_t*)0x20000c44 = 0xac; *(uint8_t*)0x20000c45 = 0x14; *(uint8_t*)0x20000c46 = 0x14; *(uint8_t*)0x20000c47 = 0xbb; *(uint32_t*)0x20000c48 = htobe32(0); *(uint32_t*)0x20000c4c = htobe32(0); *(uint32_t*)0x20000c50 = htobe32(0); *(uint32_t*)0x20000c54 = htobe32(0); *(uint32_t*)0x20000c58 = htobe32(0); *(uint32_t*)0x20000c5c = htobe32(0); *(uint32_t*)0x20000c60 = htobe32(0); *(uint32_t*)0x20000c64 = htobe32(0); memcpy((void*)0x20000c68, "vlan0\000\000\000\000\000\000\000\000\000\000\000", 16); memcpy((void*)0x20000c78, "syzkaller0\000\000\000\000\000\000", 16); *(uint8_t*)0x20000c88 = 0; *(uint8_t*)0x20000c98 = 0; *(uint16_t*)0x20000ca8 = 0; *(uint8_t*)0x20000caa = 0; *(uint8_t*)0x20000cab = 0; *(uint8_t*)0x20000cac = 0; *(uint32_t*)0x20000cb0 = 0; *(uint16_t*)0x20000cb4 = 0xa8; *(uint16_t*)0x20000cb6 = 0xf0; *(uint32_t*)0x20000cb8 = 0; *(uint64_t*)0x20000cc0 = 0; *(uint64_t*)0x20000cc8 = 0; *(uint16_t*)0x20000cd0 = 0x48; memcpy((void*)0x20000cd2, "TEE\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000", 29); *(uint8_t*)0x20000cef = 1; *(uint8_t*)0x20000cf0 = -1; *(uint8_t*)0x20000cf1 = 2; memset((void*)0x20000cf2, 0, 13); *(uint8_t*)0x20000cff = 1; memcpy((void*)0x20000d00, "netdevsim0\000\000\000\000\000\000", 16); *(uint64_t*)0x20000d10 = 0; *(uint8_t*)0x20000d18 = 0xfe; *(uint8_t*)0x20000d19 = 0x80; memset((void*)0x20000d1a, 0, 13); *(uint8_t*)0x20000d27 = 0xaa; *(uint8_t*)0x20000d28 = 0xfe; *(uint8_t*)0x20000d29 = 0x80; memset((void*)0x20000d2a, 0, 13); *(uint8_t*)0x20000d37 = 0; *(uint32_t*)0x20000d38 = htobe32(0); *(uint32_t*)0x20000d3c = htobe32(0); *(uint32_t*)0x20000d40 = htobe32(0); *(uint32_t*)0x20000d44 = htobe32(0); *(uint32_t*)0x20000d48 = htobe32(0); *(uint32_t*)0x20000d4c = htobe32(0); *(uint32_t*)0x20000d50 = htobe32(0); *(uint32_t*)0x20000d54 = htobe32(0); memcpy((void*)0x20000d58, "vlan1\000\000\000\000\000\000\000\000\000\000\000", 16); memcpy((void*)0x20000d68, "ipvlan0\000\000\000\000\000\000\000\000\000", 16); *(uint8_t*)0x20000d78 = 0; *(uint8_t*)0x20000d88 = 0; *(uint16_t*)0x20000d98 = 0; *(uint8_t*)0x20000d9a = 0; *(uint8_t*)0x20000d9b = 0; *(uint8_t*)0x20000d9c = 0; *(uint32_t*)0x20000da0 = 0; *(uint16_t*)0x20000da4 = 0x110; *(uint16_t*)0x20000da6 = 0x138; *(uint32_t*)0x20000da8 = 0; *(uint64_t*)0x20000db0 = 0; *(uint64_t*)0x20000db8 = 0; *(uint16_t*)0x20000dc0 = 0x68; memcpy((void*)0x20000dc2, "iprange\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000", 29); *(uint8_t*)0x20000ddf = 1; *(uint8_t*)0x20000de0 = 0xfe; *(uint8_t*)0x20000de1 = 0x80; memset((void*)0x20000de2, 0, 13); *(uint8_t*)0x20000def = 0xaa; *(uint8_t*)0x20000df0 = 0xfe; *(uint8_t*)0x20000df1 = 0x80; memset((void*)0x20000df2, 0, 13); *(uint8_t*)0x20000dff = 0xbb; *(uint8_t*)0x20000e00 = 0xfe; *(uint8_t*)0x20000e01 = 0x80; memset((void*)0x20000e02, 0, 13); *(uint8_t*)0x20000e0f = 0; *(uint8_t*)0x20000e10 = 0xfc; *(uint8_t*)0x20000e11 = 1; memset((void*)0x20000e12, 0, 13); *(uint8_t*)0x20000e1f = 0; *(uint8_t*)0x20000e20 = 0x41; *(uint16_t*)0x20000e28 = 0x28; memcpy((void*)0x20000e2a, "REJECT\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000", 29); *(uint8_t*)0x20000e47 = 0; *(uint32_t*)0x20000e48 = 0; memset((void*)0x20000e50, 0, 136); *(uint32_t*)0x20000ed8 = 0; *(uint16_t*)0x20000edc = 0xa8; *(uint16_t*)0x20000ede = 0xd0; *(uint32_t*)0x20000ee0 = 0; *(uint64_t*)0x20000ee8 = 0; *(uint64_t*)0x20000ef0 = 0; *(uint16_t*)0x20000ef8 = 0x28; memset((void*)0x20000efa, 0, 29); *(uint8_t*)0x20000f17 = 0; *(uint32_t*)0x20000f18 = 0xfffffffe; syscall(__NR_setsockopt, r[0], 0x29, 0x40, 0x20000ac0ul, 0x460ul); *(uint32_t*)0x2025c000 = 2; *(uint32_t*)0x2025c004 = 0x80; *(uint8_t*)0x2025c008 = 0; *(uint8_t*)0x2025c009 = 3; *(uint8_t*)0x2025c00a = 0; *(uint8_t*)0x2025c00b = 0; *(uint32_t*)0x2025c00c = 0; *(uint64_t*)0x2025c010 = 0; *(uint64_t*)0x2025c018 = 0; *(uint64_t*)0x2025c020 = 0; STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 0, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 1, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 2, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 3, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 4, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 5, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 6, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 7, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 8, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 9, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 10, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 11, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 12, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 13, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 14, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 15, 2); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 17, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 18, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 19, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 20, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 21, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 22, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 23, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 24, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 25, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 26, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 27, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 28, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 29, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 30, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 31, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 32, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 33, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 34, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 35, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 36, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 37, 1); STORE_BY_BITMASK(uint64_t, , 0x2025c028, 0, 38, 26); *(uint32_t*)0x2025c030 = 0; *(uint32_t*)0x2025c034 = 0; *(uint64_t*)0x2025c038 = 0; *(uint64_t*)0x2025c040 = 0; *(uint64_t*)0x2025c048 = 0; *(uint64_t*)0x2025c050 = 0; *(uint32_t*)0x2025c058 = 0; *(uint32_t*)0x2025c05c = 0; *(uint64_t*)0x2025c060 = 0; *(uint32_t*)0x2025c068 = 0; *(uint16_t*)0x2025c06c = 0; *(uint16_t*)0x2025c06e = 0; *(uint32_t*)0x2025c070 = 0; *(uint32_t*)0x2025c074 = 0; *(uint64_t*)0x2025c078 = 0; res = syscall(__NR_perf_event_open, 0x2025c000ul, 0, 0ul, -1, 0ul); if (res != -1) r[1] = res; syscall(__NR_close, r[1]); memcpy((void*)0x20000080, "/dev/ppp\000", 9); syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000080ul, 0ul, 0ul); memcpy( (void*)0x20000000, "\211)o " "\352\253R\\\262\036\215\275\302\227\350\254^B\v\323\026}\202\303\372v", 26); syscall(__NR_ioctl, r[1], 0xc004743e, 0x20000000ul); res = syscall(__NR_socket, 0x10ul, 3ul, 0xc); if (res != -1) r[2] = res; *(uint64_t*)0x20000100 = 0; *(uint32_t*)0x20000108 = 0; *(uint64_t*)0x20000110 = 0x200000c0; *(uint64_t*)0x200000c0 = 0x20000080; *(uint32_t*)0x20000080 = 0x2c; *(uint8_t*)0x20000084 = 0; *(uint8_t*)0x20000085 = 0xb; *(uint16_t*)0x20000086 = 0x801; *(uint32_t*)0x20000088 = 0; *(uint32_t*)0x2000008c = 0; *(uint8_t*)0x20000090 = 3; *(uint8_t*)0x20000091 = 0; *(uint16_t*)0x20000092 = htobe16(0); *(uint16_t*)0x20000094 = 8; STORE_BY_BITMASK(uint16_t, , 0x20000096, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000097, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000097, 0, 7, 1); *(uint32_t*)0x20000098 = htobe32(0); *(uint16_t*)0x2000009c = 8; STORE_BY_BITMASK(uint16_t, , 0x2000009e, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000009f, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000009f, 0, 7, 1); *(uint32_t*)0x200000a0 = htobe32(0); *(uint16_t*)0x200000a4 = 5; *(uint16_t*)0x200000a6 = 1; memset((void*)0x200000a8, 0, 1); *(uint64_t*)0x200000c8 = 0x2c; *(uint64_t*)0x20000118 = 1; *(uint64_t*)0x20000120 = 0; *(uint64_t*)0x20000128 = 0; *(uint32_t*)0x20000130 = 0; syscall(__NR_sendmsg, r[2], 0x20000100ul, 0ul); } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); loop(); return 0; }