// 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; memcpy((void*)0x20000040, "/dev/ppp\000", 9); res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000040ul, 0ul, 0ul); if (res != -1) r[0] = res; *(uint32_t*)0x20000880 = 0; syscall(__NR_ioctl, r[0], 0xc004743e, 0x20000880ul); res = syscall(__NR_socket, 0xaul, 2ul, 0x88); if (res != -1) r[1] = res; memcpy((void*)0x20007340, "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*)0x20007360 = 0xe; *(uint32_t*)0x20007364 = 4; *(uint32_t*)0x20007368 = 0x4b8; *(uint32_t*)0x2000736c = -1; *(uint32_t*)0x20007370 = 0x218; *(uint32_t*)0x20007374 = 0x318; *(uint32_t*)0x20007378 = 0; *(uint32_t*)0x2000737c = -1; *(uint32_t*)0x20007380 = -1; *(uint32_t*)0x20007384 = 0x3e8; *(uint32_t*)0x20007388 = 0x3e8; *(uint32_t*)0x2000738c = 0x3e8; *(uint32_t*)0x20007390 = -1; *(uint32_t*)0x20007394 = 4; *(uint64_t*)0x20007398 = 0; memset((void*)0x200073a0, 0, 136); *(uint32_t*)0x20007428 = 0; *(uint16_t*)0x2000742c = 0x1d0; *(uint16_t*)0x2000742e = 0x218; *(uint32_t*)0x20007430 = 0; *(uint64_t*)0x20007438 = 0; *(uint64_t*)0x20007440 = 0; *(uint16_t*)0x20007448 = 0x30; memcpy((void*)0x2000744a, "mark\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*)0x20007467 = 1; *(uint32_t*)0x20007468 = 0; *(uint32_t*)0x2000746c = 0; *(uint8_t*)0x20007470 = 0; *(uint16_t*)0x20007478 = 0xf8; memcpy((void*)0x2000747a, "recent\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*)0x20007497 = 0; *(uint32_t*)0x20007498 = 0; *(uint32_t*)0x2000749c = 0; *(uint8_t*)0x200074a0 = 2; *(uint8_t*)0x200074a1 = 0; memcpy( (void*)0x200074a2, "syz0\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\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\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\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\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\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\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\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 200); *(uint8_t*)0x2000756a = 0; *(uint16_t*)0x20007570 = 0x48; memcpy((void*)0x20007572, "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*)0x2000758f = 1; *(uint8_t*)0x20007590 = 0xfe; *(uint8_t*)0x20007591 = 0x80; memset((void*)0x20007592, 0, 13); *(uint8_t*)0x2000759f = 0xbb; memcpy((void*)0x200075a0, "wlan1\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint64_t*)0x200075b0 = 0; *(uint8_t*)0x200075b8 = 0xfe; *(uint8_t*)0x200075b9 = 0x80; memset((void*)0x200075ba, 0, 13); *(uint8_t*)0x200075c7 = 0xbb; *(uint8_t*)0x200075c8 = 0xfe; *(uint8_t*)0x200075c9 = 0x80; memset((void*)0x200075ca, 0, 13); *(uint8_t*)0x200075d7 = 0xaa; *(uint32_t*)0x200075d8 = htobe32(0); *(uint32_t*)0x200075dc = htobe32(0); *(uint32_t*)0x200075e0 = htobe32(0); *(uint32_t*)0x200075e4 = htobe32(0); *(uint32_t*)0x200075e8 = htobe32(0); *(uint32_t*)0x200075ec = htobe32(0); *(uint32_t*)0x200075f0 = htobe32(0); *(uint32_t*)0x200075f4 = htobe32(0); memcpy((void*)0x200075f8, "ip6_vti0\000\000\000\000\000\000\000\000", 16); memcpy((void*)0x20007608, "veth1_to_bond\000\000\000", 16); *(uint8_t*)0x20007618 = 0; *(uint8_t*)0x20007628 = 0; *(uint16_t*)0x20007638 = 0; *(uint8_t*)0x2000763a = 0; *(uint8_t*)0x2000763b = 0; *(uint8_t*)0x2000763c = 0; *(uint32_t*)0x20007640 = 0; *(uint16_t*)0x20007644 = 0xd8; *(uint16_t*)0x20007646 = 0x100; *(uint32_t*)0x20007648 = 0; *(uint64_t*)0x20007650 = 0; *(uint64_t*)0x20007658 = 0; *(uint16_t*)0x20007660 = 0x30; memcpy((void*)0x20007662, "realm\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*)0x2000767f = 0; *(uint32_t*)0x20007680 = 0; *(uint32_t*)0x20007684 = 0; *(uint8_t*)0x20007688 = 0; *(uint16_t*)0x20007690 = 0x28; memcpy((void*)0x20007692, "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*)0x200076af = 0; *(uint32_t*)0x200076b0 = 0; memset((void*)0x200076b8, 0, 16); memset((void*)0x200076c8, 0, 16); *(uint32_t*)0x200076d8 = htobe32(0); *(uint32_t*)0x200076dc = htobe32(0); *(uint32_t*)0x200076e0 = htobe32(0); *(uint32_t*)0x200076e4 = htobe32(0); *(uint32_t*)0x200076e8 = htobe32(0); *(uint32_t*)0x200076ec = htobe32(0); *(uint32_t*)0x200076f0 = htobe32(0); *(uint32_t*)0x200076f4 = htobe32(0); memcpy((void*)0x200076f8, "virt_wifi0\000\000\000\000\000\000", 16); memcpy((void*)0x20007708, "team0\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint8_t*)0x20007718 = 0; *(uint8_t*)0x20007728 = 0; *(uint16_t*)0x20007738 = 0; *(uint8_t*)0x2000773a = 0; *(uint8_t*)0x2000773b = 0; *(uint8_t*)0x2000773c = 0; *(uint32_t*)0x20007740 = 0; *(uint16_t*)0x20007744 = 0xa8; *(uint16_t*)0x20007746 = 0xd0; *(uint32_t*)0x20007748 = 0; *(uint64_t*)0x20007750 = 0; *(uint64_t*)0x20007758 = 0; *(uint16_t*)0x20007760 = 0x28; memcpy((void*)0x20007762, "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*)0x2000777f = 0; *(uint32_t*)0x20007780 = 0; memset((void*)0x20007788, 0, 136); *(uint32_t*)0x20007810 = 0; *(uint16_t*)0x20007814 = 0xa8; *(uint16_t*)0x20007816 = 0xd0; *(uint32_t*)0x20007818 = 0; *(uint64_t*)0x20007820 = 0; *(uint64_t*)0x20007828 = 0; *(uint16_t*)0x20007830 = 0x28; memset((void*)0x20007832, 0, 29); *(uint8_t*)0x2000784f = 0; *(uint32_t*)0x20007850 = 0xfffffffe; syscall(__NR_setsockopt, r[1], 0x29, 0x40, 0x20007340ul, 0x518ul); 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 = 0x20000040; *(uint32_t*)0x20000040 = 0x2c; *(uint8_t*)0x20000044 = 0; *(uint8_t*)0x20000045 = 0xb; *(uint16_t*)0x20000046 = 0x801; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x2000004c = 0; *(uint8_t*)0x20000050 = 3; *(uint8_t*)0x20000051 = 0; *(uint16_t*)0x20000052 = htobe16(0); *(uint16_t*)0x20000054 = 5; *(uint16_t*)0x20000056 = 1; memset((void*)0x20000058, 0, 1); *(uint16_t*)0x2000005c = 8; STORE_BY_BITMASK(uint16_t, , 0x2000005e, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000005f, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000005f, 0, 7, 1); *(uint32_t*)0x20000060 = htobe32(0); *(uint16_t*)0x20000064 = 8; STORE_BY_BITMASK(uint16_t, , 0x20000066, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20000067, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20000067, 0, 7, 1); *(uint32_t*)0x20000068 = htobe32(0); *(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; }