// https://syzkaller.appspot.com/bug?id=b4b82fbf2f5c575e559e31893b95b393248f5333 // 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 #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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 70 72 6f 63 00} (length 0x7) // } // mode: open_mode = 0x1ff (8 bytes) // ] memcpy((void*)0x200000000100, "./proc\000", 7); syscall( __NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000100ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|S_IXGRP|S_IWGRP|S_IRGRP|S_IXUSR|S_IWUSR|0x100*/ 0x1fful); // mount arguments: [ // src: nil // dst: ptr[in, buffer] { // buffer: {2e 2f 70 72 6f 63 00} (length 0x7) // } // type: ptr[in, buffer] { // buffer: {70 72 6f 63 00} (length 0x5) // } // flags: mount_flags = 0x0 (8 bytes) // data: nil // ] memcpy((void*)0x200000000100, "./proc\000", 7); memcpy((void*)0x200000000140, "proc\000", 5); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x200000000100ul, /*type=*/0x200000000140ul, /*flags=*/0ul, /*data=*/0ul); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 70 72 6f 63 2f 73 79 73 2f 6e 65 74 2f 69 70 76 36 2f // 63 6f 6e 66 2f 6c 6f 2f 6b 65 65 70 5f 61 64 64 72 5f 6f 6e 5f 64 6f // 77 6e 00} (length 0x2e) // } // flags: open_flags = 0x2 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000000, "./proc/sys/net/ipv6/conf/lo/keep_addr_on_down\000", 46); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000000ul, /*flags=O_RDWR*/ 2, /*mode=*/0); if (res != -1) r[0] = res; // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {31 0a} (length 0x2) // } // count: len = 0x2 (8 bytes) // ] memcpy((void*)0x200000000040, "1\n", 2); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x200000000040ul, /*count=*/2ul); // socket$inet6 arguments: [ // domain: const = 0xa (8 bytes) // type: socket_type = 0x2 (8 bytes) // proto: int32 = 0x0 (4 bytes) // ] // returns sock_in6 res = syscall(__NR_socket, /*domain=*/0xaul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0); if (res != -1) r[1] = res; // ioctl$sock_inet6_SIOCSIFADDR arguments: [ // fd: sock_in6 (resource) // cmd: const = 0x8916 (4 bytes) // arg: ptr[in, in6_ifreq] { // in6_ifreq { // ifr6_addr: union ipv6_addr { // private0: ipv6_addr_private[0] { // a0: const = 0xfc (1 bytes) // a1: const = 0x0 (1 bytes) // a2: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00} (length // 0xd) a3: int8 = 0x0 (1 bytes) // } // } // ifr6_prefixlen: int32 = 0x40 (4 bytes) // ifr6_ifindex: ifindex (resource) // } // } // ] *(uint8_t*)0x200000000080 = 0xfc; *(uint8_t*)0x200000000081 = 0; memset((void*)0x200000000082, 0, 13); *(uint8_t*)0x20000000008f = 0; *(uint32_t*)0x200000000090 = 0x40; *(uint32_t*)0x200000000094 = 1; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x8916, /*arg=*/0x200000000080ul); // socket$netlink arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: netlink_proto = 0x0 (4 bytes) // ] // returns sock_netlink res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); if (res != -1) r[2] = res; // writev arguments: [ // fd: fd (resource) // vec: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {39 00 00 00 13 00 03 47 00 bb 65 e1 c3 e4 ff ff 01 00 // 00 00 01 00 00 00 56 00 00 00 25 00 00 00 19 00 04 00 04 00 00 // 00 07 fd 17 e5 ff ff 08 00 04 00 00 00 00 00 00 00 00} (length // 0x39) // } // len: len = 0x39 (8 bytes) // } // } // } // vlen: len = 0x1 (8 bytes) // ] *(uint64_t*)0x2000000003c0 = 0x200000000180; memcpy((void*)0x200000000180, "\x39\x00\x00\x00\x13\x00\x03\x47\x00\xbb\x65\xe1\xc3\xe4\xff\xff\x01" "\x00\x00\x00\x01\x00\x00\x00\x56\x00\x00\x00\x25\x00\x00\x00\x19\x00" "\x04\x00\x04\x00\x00\x00\x07\xfd\x17\xe5\xff\xff\x08\x00\x04\x00\x00" "\x00\x00\x00\x00\x00\x00", 57); *(uint64_t*)0x2000000003c8 = 0x39; syscall(__NR_writev, /*fd=*/r[2], /*vec=*/0x2000000003c0ul, /*vlen=*/1ul); // socket$nl_route arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_nl_route res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); if (res != -1) r[3] = res; // sendmsg$nl_route arguments: [ // fd: sock_nl_route (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_route]] { // msghdr_netlink[netlink_msg_route] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_route]] { // iovec[in, netlink_msg_route] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {28 00 00 00 10 00 01 00 24 bd 70 00 fc // 0d df 25 00 00 00 00} (length 0x14) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {1b 0b 04 00 03 00 00 00 08 00 1b} // (length 0xb) // } // } // } // len: len = 0x28 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x68010 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000000200 = 0; *(uint32_t*)0x200000000208 = 0; *(uint64_t*)0x200000000210 = 0x200000000180; *(uint64_t*)0x200000000180 = 0x2000000000c0; memcpy((void*)0x2000000000c0, "\x28\x00\x00\x00\x10\x00\x01\x00\x24\xbd\x70\x00\xfc\x0d\xdf\x25\x00" "\x00\x00\x00", 20); *(uint32_t*)0x2000000000d4 = 0; memcpy((void*)0x2000000000d8, "\x1b\x0b\x04\x00\x03\x00\x00\x00\x08\x00\x1b", 11); *(uint64_t*)0x200000000188 = 0x28; *(uint64_t*)0x200000000218 = 1; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 0; *(uint32_t*)0x200000000230 = 0x68010; syscall(__NR_sendmsg, /*fd=*/r[3], /*msg=*/0x200000000200ul, /*f=*/0ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }