// https://syzkaller.appspot.com/bug?id=df12e4be06dc87ca909200e67e2b2214bfc96288 // 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; } 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$inet_sctp arguments: [ // domain: const = 0x2 (8 bytes) // type: sctp_socket_type = 0x1 (8 bytes) // proto: const = 0x84 (4 bytes) // ] // returns sock_sctp res = syscall(__NR_socket, /*domain=*/2ul, /*type=SOCK_STREAM*/ 1ul, /*proto=*/0x84); if (res != -1) r[0] = res; // setsockopt$IP_VS_SO_SET_ADD arguments: [ // fd: sock_in (resource) // level: const = 0x0 (4 bytes) // opt: const = 0x482 (4 bytes) // val: ptr[in, ip_vs_service_user] { // ip_vs_service_user { // protocol: ipv6_types = 0x84 (2 bytes) // pad = 0x0 (2 bytes) // addr: union ipv4_addr { // broadcast: const = 0xffffffff (4 bytes) // } // port: int16be = 0x4e21 (2 bytes) // pad = 0x0 (2 bytes) // fwmark: int32 = 0x3 (4 bytes) // sched_name: buffer: {72 72 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x10) flags: ip_vs_flags = 0x1 (4 bytes) timeout: int32 // = 0x10000004 (4 bytes) netmask: int32be = 0x8 (4 bytes) // } // } // len: len = 0x2c (8 bytes) // ] *(uint16_t*)0x200000000040 = 0x84; *(uint32_t*)0x200000000044 = htobe32(-1); *(uint16_t*)0x200000000048 = htobe16(0x4e21); *(uint32_t*)0x20000000004c = 3; memcpy((void*)0x200000000050, "rr\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000060 = 1; *(uint32_t*)0x200000000064 = 0x10000004; *(uint32_t*)0x200000000068 = htobe32(8); syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/0x482, /*val=*/0x200000000040ul, /*len=*/0x2cul); // socket$kcm arguments: [ // domain: const = 0xa (8 bytes) // type: kcm_socket_type = 0x2 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_kcm res = syscall(__NR_socket, /*domain=*/0xaul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0); if (res != -1) r[1] = res; // setsockopt$IP_VS_SO_SET_ADDDEST arguments: [ // fd: sock_in (resource) // level: const = 0x0 (4 bytes) // opt: const = 0x487 (4 bytes) // val: ptr[in, ip_vs_svcdest_user] { // ip_vs_svcdest_user { // s: ip_vs_service_user { // protocol: ipv6_types = 0x84 (2 bytes) // pad = 0x0 (2 bytes) // addr: union ipv4_addr { // private: int32be = 0xa010101 (4 bytes) // } // port: int16be = 0x4e21 (2 bytes) // pad = 0x0 (2 bytes) // fwmark: int32 = 0x3 (4 bytes) // sched_name: buffer: {77 72 72 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x10) flags: ip_vs_flags = 0x23 (4 bytes) timeout: // int32 = 0x80 (4 bytes) netmask: int32be = 0x5d (4 bytes) // } // d: ip_vs_dest_user { // addr: union ipv4_addr { // dev: ipv4_addr_t[netdev_addr_id] { // a0: const = 0xac (1 bytes) // a1: const = 0x14 (1 bytes) // a2: const = 0x14 (1 bytes) // a3: int8 = 0x43 (1 bytes) // } // } // port: int16be = 0x4e24 (2 bytes) // pad = 0x0 (2 bytes) // conn_flags: ipvs_conn_flags = 0x4 (4 bytes) // weight: int32 = 0x1cb (4 bytes) // u_threshold: int32 = 0x12d61 (4 bytes) // l_threshold: int32 = 0x5 (4 bytes) // } // } // } // len: len = 0x44 (8 bytes) // ] *(uint16_t*)0x200000000000 = 0x84; *(uint32_t*)0x200000000004 = htobe32(0xa010101); *(uint16_t*)0x200000000008 = htobe16(0x4e21); *(uint32_t*)0x20000000000c = 3; memcpy((void*)0x200000000010, "wrr\000\000\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x200000000020 = 0x23; *(uint32_t*)0x200000000024 = 0x80; *(uint32_t*)0x200000000028 = htobe32(0x5d); *(uint8_t*)0x20000000002c = 0xac; *(uint8_t*)0x20000000002d = 0x14; *(uint8_t*)0x20000000002e = 0x14; *(uint8_t*)0x20000000002f = 0x43; *(uint16_t*)0x200000000030 = htobe16(0x4e24); *(uint32_t*)0x200000000034 = 4; *(uint32_t*)0x200000000038 = 0x1cb; *(uint32_t*)0x20000000003c = 0x12d61; *(uint32_t*)0x200000000040 = 5; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/0x487, /*val=*/0x200000000000ul, /*len=*/0x44ul); // sendmsg$sock arguments: [ // fd: sock (resource) // msg: ptr[in, msghdr_sock] { // msghdr_sock { // msg_name: ptr[in, sockaddr_storage] { // union sockaddr_storage { // in6: sockaddr_in6 { // family: const = 0x2 (2 bytes) // port: int16be = 0x4e22 (2 bytes) // flow: int32be = 0x0 (4 bytes) // addr: union ipv6_addr { // dev: ipv6_addr_t[netdev_addr_id] { // a0: const = 0xfe (1 bytes) // a1: const = 0x80 (1 bytes) // a2: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xd) a3: int8 = 0x0 (1 bytes) // } // } // scope: int32 = 0xfffffeec (4 bytes) // } // } // } // msg_namelen: len = 0x80 (4 bytes) // pad = 0x0 (4 bytes) // msg_iov: nil // msg_iovlen: len = 0x0 (8 bytes) // msg_control: ptr[in, array[cmsghdr_sock]] { // array[cmsghdr_sock] { // union cmsghdr_sock { // mark: cmsghdr_t[SOL_SOCKET, SO_MARK, int32] { // unaligned: cmsghdr_unaligned[SOL_SOCKET, SO_MARK, int32] { // cmsg_len: len = 0x14 (8 bytes) // cmsg_level: const = 0x1 (4 bytes) // cmsg_type: const = 0x24 (4 bytes) // data: int32 = 0x3 (4 bytes) // } // pad = 0x0 (4 bytes) // } // } // } // } // msg_controllen: bytesize = 0x18 (8 bytes) // msg_flags: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000000400 = 0x200000000580; *(uint16_t*)0x200000000580 = 2; *(uint16_t*)0x200000000582 = htobe16(0x4e22); *(uint32_t*)0x200000000584 = htobe32(0); *(uint8_t*)0x200000000588 = 0xfe; *(uint8_t*)0x200000000589 = 0x80; memset((void*)0x20000000058a, 0, 13); *(uint8_t*)0x200000000597 = 0; *(uint32_t*)0x200000000598 = 0xfffffeec; *(uint32_t*)0x200000000408 = 0x80; *(uint64_t*)0x200000000410 = 0; *(uint64_t*)0x200000000418 = 0; *(uint64_t*)0x200000000420 = 0x200000000000; *(uint64_t*)0x200000000000 = 0x14; *(uint32_t*)0x200000000008 = 1; *(uint32_t*)0x20000000000c = 0x24; *(uint32_t*)0x200000000010 = 3; *(uint64_t*)0x200000000428 = 0x18; *(uint32_t*)0x200000000430 = 0; syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000000400ul, /*f=*/0ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }