// https://syzkaller.appspot.com/bug?id=b37fc58e1fe10fd8fe2bdb06b59eff86d0f18ba4 // 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; } const int kInitNetNsFd = 201; static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto) { return syscall(__NR_socket, domain, type, proto); } 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // syz_init_net_socket$802154_dgram arguments: [ // domain: const = 0x24 (8 bytes) // type: const = 0x2 (8 bytes) // proto: const = 0x0 (8 bytes) // ] // returns sock_802154_dgram res = -1; res = syz_init_net_socket(/*domain=*/0x24, /*type=*/2, /*proto=*/0); if (res != -1) r[0] = res; // setsockopt$WPAN_SECURITY arguments: [ // fd: sock_802154_dgram (resource) // level: const = 0x0 (4 bytes) // opt: const = 0x1 (4 bytes) // val: ptr[in, ieee802154_security] { // ieee802154_security = 0x2 (4 bytes) // } // len: bytesize = 0x4 (8 bytes) // ] *(uint32_t*)0x200000000040 = 2; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/1, /*val=*/0x200000000040ul, /*len=*/4ul); // setsockopt$WPAN_SECURITY arguments: [ // fd: sock_802154_dgram (resource) // level: const = 0x0 (4 bytes) // opt: const = 0x1 (4 bytes) // val: ptr[in, ieee802154_security] { // ieee802154_security = 0x0 (4 bytes) // } // len: bytesize = 0x4 (8 bytes) // ] *(uint32_t*)0x200000000080 = 0; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/1, /*val=*/0x200000000080ul, /*len=*/4ul); // sendmsg$802154_dgram arguments: [ // fd: sock_802154_dgram (resource) // msg: ptr[in, msghdr_802154] { // msghdr_802154 { // addr: ptr[in, sockaddr_ieee802154] { // sockaddr_ieee802154 { // family: const = 0x24 (2 bytes) // pad = 0x0 (2 bytes) // addr: union ieee802154_addr_sa { // short: ieee802154_addr_sa_t[IEEE802154_ADDR_SHORT, // flags[ieee802154_short_addr, int16]] { // addr_type: const = 0x2 (4 bytes) // pan_id: ieee802154_pan_id = 0x3 (2 bytes) // addr: ieee802154_short_addr = 0xfffe (2 bytes) // } // } // } // } // addrlen: len = 0x14 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x4040044 (8 bytes) // ] *(uint64_t*)0x200000002480 = 0x200000002380; *(uint16_t*)0x200000002380 = 0x24; *(uint32_t*)0x200000002384 = 2; *(uint16_t*)0x200000002388 = 3; *(uint16_t*)0x20000000238a = 0xfffe; *(uint32_t*)0x200000002488 = 0x14; *(uint64_t*)0x200000002490 = 0x200000002440; *(uint64_t*)0x200000002440 = 0; *(uint64_t*)0x200000002448 = 0; *(uint64_t*)0x200000002498 = 1; *(uint64_t*)0x2000000024a0 = 0; *(uint64_t*)0x2000000024a8 = 0; *(uint32_t*)0x2000000024b0 = 0; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000002480ul, /*f=MSG_ZEROCOPY|MSG_BATCH|MSG_DONTWAIT|MSG_DONTROUTE*/ 0x4040044ul); } 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; }