// https://syzkaller.appspot.com/bug?id=5388824c1e18a045263859c865be0409bc5459bf // 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 #ifndef __NR_ioctl #define __NR_ioctl 29 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_sendmsg #define __NR_sendmsg 211 #endif #ifndef __NR_socket #define __NR_socket 198 #endif #ifndef __NR_socketpair #define __NR_socketpair 199 #endif 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; *(uint64_t*)0x200000c0 = 0; *(uint32_t*)0x200000c8 = 0; *(uint64_t*)0x200000d0 = 0x20000080; *(uint64_t*)0x20000080 = 0x20000280; *(uint32_t*)0x20000280 = 0x1c4; *(uint16_t*)0x20000284 = 0x31; *(uint16_t*)0x20000286 = 0x100; *(uint32_t*)0x20000288 = 0x70bd27; *(uint32_t*)0x2000028c = 0x25dfdbfb; *(uint8_t*)0x20000290 = 0; *(uint8_t*)0x20000291 = 0; *(uint16_t*)0x20000292 = 0; *(uint16_t*)0x20000294 = 0x20; *(uint16_t*)0x20000296 = 1; *(uint16_t*)0x20000298 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x2000029a, 0x14, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000029b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000029b, 0, 7, 1); *(uint16_t*)0x2000029c = 9; *(uint16_t*)0x2000029e = 1; memcpy((void*)0x200002a0, "csum\000", 5); *(uint16_t*)0x200002a8 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x200002aa, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002ab, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002ab, 0, 7, 1); *(uint16_t*)0x200002ac = 8; *(uint16_t*)0x200002ae = 1; memcpy((void*)0x200002b0, "ipt\000", 4); *(uint16_t*)0x200002b4 = 0x18; *(uint16_t*)0x200002b6 = 1; *(uint16_t*)0x200002b8 = 0x14; STORE_BY_BITMASK(uint16_t, , 0x200002ba, 0, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002bb, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002bb, 0, 7, 1); *(uint16_t*)0x200002bc = 0xd; *(uint16_t*)0x200002be = 1; memcpy((void*)0x200002c0, "connmark\000", 9); *(uint16_t*)0x200002cc = 0x30; *(uint16_t*)0x200002ce = 1; *(uint16_t*)0x200002d0 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x200002d2, 0x1b, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002d3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002d3, 0, 7, 1); *(uint16_t*)0x200002d4 = 0xb; *(uint16_t*)0x200002d6 = 1; memcpy((void*)0x200002d8, "skbmod\000", 7); *(uint16_t*)0x200002e0 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x200002e2, 0x14, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002e3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002e3, 0, 7, 1); *(uint16_t*)0x200002e4 = 8; *(uint16_t*)0x200002e6 = 3; *(uint32_t*)0x200002e8 = 8; *(uint16_t*)0x200002ec = 0x10; STORE_BY_BITMASK(uint16_t, , 0x200002ee, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200002ef, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200002ef, 0, 7, 1); *(uint16_t*)0x200002f0 = 9; *(uint16_t*)0x200002f2 = 1; memcpy((void*)0x200002f4, "csum\000", 5); *(uint16_t*)0x200002fc = 0x38; *(uint16_t*)0x200002fe = 1; *(uint16_t*)0x20000300 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x20000302, 0x12, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000303, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000303, 0, 7, 1); *(uint16_t*)0x20000304 = 8; *(uint16_t*)0x20000306 = 3; *(uint32_t*)0x20000308 = 8; *(uint16_t*)0x2000030c = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000030e, 0, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000030f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000030f, 0, 7, 1); *(uint16_t*)0x20000310 = 8; *(uint16_t*)0x20000312 = 3; *(uint32_t*)0x20000314 = 0x7fff; *(uint16_t*)0x20000318 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x2000031a, 0x10, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000031b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000031b, 0, 7, 1); *(uint16_t*)0x2000031c = 9; *(uint16_t*)0x2000031e = 1; memcpy((void*)0x20000320, "gact\000", 5); *(uint16_t*)0x20000328 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000032a, 0xd, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000032b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000032b, 0, 7, 1); *(uint16_t*)0x2000032c = 8; *(uint16_t*)0x2000032e = 3; *(uint32_t*)0x20000330 = 0x800; *(uint16_t*)0x20000334 = 0x84; *(uint16_t*)0x20000336 = 1; *(uint16_t*)0x20000338 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000033a, 4, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000033b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000033b, 0, 7, 1); *(uint16_t*)0x2000033c = 8; *(uint16_t*)0x2000033e = 3; *(uint32_t*)0x20000340 = 1; *(uint16_t*)0x20000344 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x20000346, 1, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000347, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000347, 0, 7, 1); *(uint16_t*)0x20000348 = 0xb; *(uint16_t*)0x2000034a = 1; memcpy((void*)0x2000034c, "sample\000", 7); *(uint16_t*)0x20000354 = 0x14; STORE_BY_BITMASK(uint16_t, , 0x20000356, 0x1e, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000357, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000357, 0, 7, 1); *(uint16_t*)0x20000358 = 0xd; *(uint16_t*)0x2000035a = 1; memcpy((void*)0x2000035c, "connmark\000", 9); *(uint16_t*)0x20000368 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000036a, 0xa, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000036b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000036b, 0, 7, 1); *(uint16_t*)0x2000036c = 8; *(uint16_t*)0x2000036e = 3; *(uint32_t*)0x20000370 = 0x80000000; *(uint16_t*)0x20000374 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x20000376, 0x12, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000377, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000377, 0, 7, 1); *(uint16_t*)0x20000378 = 8; *(uint16_t*)0x2000037a = 3; *(uint32_t*)0x2000037c = 0x7f; *(uint16_t*)0x20000380 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x20000382, 9, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000383, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000383, 0, 7, 1); *(uint16_t*)0x20000384 = 0xb; *(uint16_t*)0x20000386 = 1; memcpy((void*)0x20000388, "police\000", 7); *(uint16_t*)0x20000390 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x20000392, 0, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000393, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000393, 0, 7, 1); *(uint16_t*)0x20000394 = 8; *(uint16_t*)0x20000396 = 3; *(uint32_t*)0x20000398 = 0x8dc7; *(uint16_t*)0x2000039c = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000039e, 0x13, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000039f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000039f, 0, 7, 1); *(uint16_t*)0x200003a0 = 8; *(uint16_t*)0x200003a2 = 1; memcpy((void*)0x200003a4, "ipt\000", 4); *(uint16_t*)0x200003a8 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x200003aa, 0x17, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003ab, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003ab, 0, 7, 1); *(uint16_t*)0x200003ac = 9; *(uint16_t*)0x200003ae = 1; memcpy((void*)0x200003b0, "gact\000", 5); *(uint16_t*)0x200003b8 = 0x54; *(uint16_t*)0x200003ba = 1; *(uint16_t*)0x200003bc = 0xc; STORE_BY_BITMASK(uint16_t, , 0x200003be, 0xc, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003bf, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003bf, 0, 7, 1); *(uint16_t*)0x200003c0 = 8; *(uint16_t*)0x200003c2 = 3; *(uint32_t*)0x200003c4 = 0x4a0e; *(uint16_t*)0x200003c8 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x200003ca, 5, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003cb, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003cb, 0, 7, 1); *(uint16_t*)0x200003cc = 8; *(uint16_t*)0x200003ce = 3; *(uint32_t*)0x200003d0 = 0x1f; *(uint16_t*)0x200003d4 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x200003d6, 0x17, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003d7, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003d7, 0, 7, 1); *(uint16_t*)0x200003d8 = 8; *(uint16_t*)0x200003da = 3; *(uint32_t*)0x200003dc = 0xffffff20; *(uint16_t*)0x200003e0 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x200003e2, 0x13, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003e3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003e3, 0, 7, 1); *(uint16_t*)0x200003e4 = 8; *(uint16_t*)0x200003e6 = 1; memcpy((void*)0x200003e8, "ipt\000", 4); *(uint16_t*)0x200003ec = 0x10; STORE_BY_BITMASK(uint16_t, , 0x200003ee, 6, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003ef, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003ef, 0, 7, 1); *(uint16_t*)0x200003f0 = 0xb; *(uint16_t*)0x200003f2 = 1; memcpy((void*)0x200003f4, "sample\000", 7); *(uint16_t*)0x200003fc = 0x10; STORE_BY_BITMASK(uint16_t, , 0x200003fe, 0x18, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x200003ff, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x200003ff, 0, 7, 1); *(uint16_t*)0x20000400 = 0xb; *(uint16_t*)0x20000402 = 1; memcpy((void*)0x20000404, "mirred\000", 7); *(uint16_t*)0x2000040c = 0x38; *(uint16_t*)0x2000040e = 1; *(uint16_t*)0x20000410 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x20000412, 0x1b, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000413, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000413, 0, 7, 1); *(uint16_t*)0x20000414 = 8; *(uint16_t*)0x20000416 = 3; *(uint32_t*)0x20000418 = 0; *(uint16_t*)0x2000041c = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000041e, 9, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000041f, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000041f, 0, 7, 1); *(uint16_t*)0x20000420 = 8; *(uint16_t*)0x20000422 = 3; *(uint32_t*)0x20000424 = 2; *(uint16_t*)0x20000428 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000042a, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000042b, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000042b, 0, 7, 1); *(uint16_t*)0x2000042c = 8; *(uint16_t*)0x2000042e = 1; memcpy((void*)0x20000430, "bpf\000", 4); *(uint16_t*)0x20000434 = 0x10; STORE_BY_BITMASK(uint16_t, , 0x20000436, 0x10, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000437, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000437, 0, 7, 1); *(uint16_t*)0x20000438 = 0xa; *(uint16_t*)0x2000043a = 1; memcpy((void*)0x2000043c, "pedit\000", 6); *(uint64_t*)0x20000088 = 0x1c4; *(uint64_t*)0x200000d8 = 1; *(uint64_t*)0x200000e0 = 0; *(uint64_t*)0x200000e8 = 0; *(uint32_t*)0x200000f0 = 0x44040; syscall(__NR_sendmsg, /*fd=*/-1, /*msg=*/0x200000c0ul, /*f=*/0x8010ul); res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); if (res != -1) r[0] = res; res = syscall(__NR_socketpair, /*domain=*/1ul, /*type=*/1ul, /*proto=*/0, /*fds=*/0x20000080ul); if (res != -1) r[1] = *(uint32_t*)0x20000084; memcpy((void*)0x20000000, "lo\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16); res = syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x8933, /*arg=*/0x20000000ul); if (res != -1) r[2] = *(uint32_t*)0x20000010; *(uint64_t*)0x20000000 = 0; *(uint32_t*)0x20000008 = 0; *(uint64_t*)0x20000010 = 0x20000780; *(uint64_t*)0x20000780 = 0x200002c0; memcpy((void*)0x200002c0, "\x78\x00\x00\x00\x24\x00\x0b\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x60" "\x00\x00\x00", 20); *(uint32_t*)0x200002d4 = r[2]; memcpy((void*)0x200002d8, "\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x0a\x00\x01\x00\x6e" "\x65\x74\x65\x6d\x00\x04\x00\x48\x00\x02\x00\x00\x00\x00\x00\x86\x00" "\x02\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\xff\xff\xff\xff", 50); *(uint64_t*)0x20000788 = 0x78; *(uint64_t*)0x20000018 = 1; *(uint64_t*)0x20000020 = 0; *(uint64_t*)0x20000028 = 0; *(uint32_t*)0x20000030 = 0; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x20000000ul, /*f=*/0ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); loop(); return 0; }