// https://syzkaller.appspot.com/bug?id=6c9acdee375e8b5520c144be6844b1a0aa803924 // 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_bpf #define __NR_bpf 321 #endif static unsigned long long procid; 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 (;;) { 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)) { } *(uint32_t*)0x4000000000c0 = 0x1b; *(uint32_t*)0x4000000000c4 = 0; *(uint32_t*)0x4000000000c8 = 0; *(uint32_t*)0x4000000000cc = 0x8000; *(uint32_t*)0x4000000000d0 = 0; *(uint32_t*)0x4000000000d4 = -1; *(uint32_t*)0x4000000000d8 = 0; memset((void*)0x4000000000dc, 0, 16); *(uint32_t*)0x4000000000ec = 0; *(uint32_t*)0x4000000000f0 = -1; *(uint32_t*)0x4000000000f4 = 0; *(uint32_t*)0x4000000000f8 = 0; *(uint32_t*)0x4000000000fc = 0; *(uint64_t*)0x400000000100 = 0; *(uint32_t*)0x400000000108 = 0; *(uint32_t*)0x40000000010c = 0; res = syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x4000000000c0ul, /*size=*/0x48ul); if (res != -1) r[0] = res; *(uint32_t*)0x400000000600 = 0x11; *(uint32_t*)0x400000000604 = 0x17; *(uint64_t*)0x400000000608 = 0x400000000a00; *(uint8_t*)0x400000000a00 = 0x18; STORE_BY_BITMASK(uint8_t, , 0x400000000a01, 0, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a01, 0, 4, 4); *(uint16_t*)0x400000000a02 = 0; *(uint32_t*)0x400000000a04 = 0x100; *(uint8_t*)0x400000000a08 = 0; *(uint8_t*)0x400000000a09 = 0; *(uint16_t*)0x400000000a0a = 0; *(uint32_t*)0x400000000a0c = 0xa; *(uint8_t*)0x400000000a10 = 0x18; STORE_BY_BITMASK(uint8_t, , 0x400000000a11, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a11, 1, 4, 4); *(uint16_t*)0x400000000a12 = 0; *(uint32_t*)0x400000000a14 = r[0]; *(uint8_t*)0x400000000a18 = 0; *(uint8_t*)0x400000000a19 = 0; *(uint16_t*)0x400000000a1a = 0; *(uint32_t*)0x400000000a1c = 0; STORE_BY_BITMASK(uint8_t, , 0x400000000a20, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a20, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a20, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a21, 2, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a21, 0, 4, 4); *(uint16_t*)0x400000000a22 = 0; *(uint32_t*)0x400000000a24 = 0x14; STORE_BY_BITMASK(uint8_t, , 0x400000000a28, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a28, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a28, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a29, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a29, 0, 4, 4); *(uint16_t*)0x400000000a2a = 0; *(uint32_t*)0x400000000a2c = 0; *(uint8_t*)0x400000000a30 = 0x85; *(uint8_t*)0x400000000a31 = 0; *(uint16_t*)0x400000000a32 = 0; *(uint32_t*)0x400000000a34 = 0x83; STORE_BY_BITMASK(uint8_t, , 0x400000000a38, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a38, 1, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a38, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a39, 9, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a39, 0, 4, 4); *(uint16_t*)0x400000000a3a = 0; *(uint32_t*)0x400000000a3c = 0; STORE_BY_BITMASK(uint8_t, , 0x400000000a40, 5, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a40, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a40, 5, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a41, 9, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a41, 0, 4, 4); *(uint16_t*)0x400000000a42 = 1; *(uint32_t*)0x400000000a44 = 0; *(uint8_t*)0x400000000a48 = 0x95; *(uint8_t*)0x400000000a49 = 0; *(uint16_t*)0x400000000a4a = 0; *(uint32_t*)0x400000000a4c = 0; *(uint8_t*)0x400000000a50 = 0x18; STORE_BY_BITMASK(uint8_t, , 0x400000000a51, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a51, 0, 4, 4); *(uint16_t*)0x400000000a52 = 0; *(uint32_t*)0x400000000a54 = 0x256c7820; *(uint8_t*)0x400000000a58 = 0; *(uint8_t*)0x400000000a59 = 0; *(uint16_t*)0x400000000a5a = 0; *(uint32_t*)0x400000000a5c = 0x20202000; STORE_BY_BITMASK(uint8_t, , 0x400000000a60, 3, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a60, 3, 3, 2); STORE_BY_BITMASK(uint8_t, , 0x400000000a60, 3, 5, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a61, 0xa, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a61, 1, 4, 4); *(uint16_t*)0x400000000a62 = 0xfff8; *(uint32_t*)0x400000000a64 = 0; STORE_BY_BITMASK(uint8_t, , 0x400000000a68, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a68, 1, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a68, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a69, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a69, 0xa, 4, 4); *(uint16_t*)0x400000000a6a = 0; *(uint32_t*)0x400000000a6c = 0; STORE_BY_BITMASK(uint8_t, , 0x400000000a70, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a70, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a70, 0, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a71, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a71, 0, 4, 4); *(uint16_t*)0x400000000a72 = 0; *(uint32_t*)0x400000000a74 = 0xfffffff8; STORE_BY_BITMASK(uint8_t, , 0x400000000a78, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a78, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a78, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a79, 2, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a79, 0, 4, 4); *(uint16_t*)0x400000000a7a = 0; *(uint32_t*)0x400000000a7c = 8; STORE_BY_BITMASK(uint8_t, , 0x400000000a80, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a80, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a80, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a81, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a81, 0, 4, 4); *(uint16_t*)0x400000000a82 = 0; *(uint32_t*)0x400000000a84 = 0; *(uint8_t*)0x400000000a88 = 0x85; *(uint8_t*)0x400000000a89 = 0; *(uint16_t*)0x400000000a8a = 0; *(uint32_t*)0x400000000a8c = 6; STORE_BY_BITMASK(uint8_t, , 0x400000000a90, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a90, 1, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a90, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a91, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a91, 9, 4, 4); *(uint16_t*)0x400000000a92 = 0; *(uint32_t*)0x400000000a94 = 0; STORE_BY_BITMASK(uint8_t, , 0x400000000a98, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000a98, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000a98, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a99, 2, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000a99, 0, 4, 4); *(uint16_t*)0x400000000a9a = 0; *(uint32_t*)0x400000000a9c = 0; *(uint8_t*)0x400000000aa0 = 0x85; *(uint8_t*)0x400000000aa1 = 0; *(uint16_t*)0x400000000aa2 = 0; *(uint32_t*)0x400000000aa4 = 0x85; STORE_BY_BITMASK(uint8_t, , 0x400000000aa8, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x400000000aa8, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x400000000aa8, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000aa9, 0, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x400000000aa9, 0, 4, 4); *(uint16_t*)0x400000000aaa = 0; *(uint32_t*)0x400000000aac = 0; *(uint8_t*)0x400000000ab0 = 0x95; *(uint8_t*)0x400000000ab1 = 0; *(uint16_t*)0x400000000ab2 = 0; *(uint32_t*)0x400000000ab4 = 0; *(uint64_t*)0x400000000610 = 0x4000000003c0; memcpy((void*)0x4000000003c0, "GPL\000", 4); *(uint32_t*)0x400000000618 = 0; *(uint32_t*)0x40000000061c = 0; *(uint64_t*)0x400000000620 = 0; *(uint32_t*)0x400000000628 = 0x41100; *(uint32_t*)0x40000000062c = 8; memset((void*)0x400000000630, 0, 16); *(uint32_t*)0x400000000640 = 0; *(uint32_t*)0x400000000644 = 0; *(uint32_t*)0x400000000648 = -1; *(uint32_t*)0x40000000064c = 8; *(uint64_t*)0x400000000650 = 0; *(uint32_t*)0x400000000658 = 0; *(uint32_t*)0x40000000065c = 0x10; *(uint64_t*)0x400000000660 = 0; *(uint32_t*)0x400000000668 = 0; *(uint32_t*)0x40000000066c = 0; *(uint32_t*)0x400000000670 = 0; *(uint32_t*)0x400000000674 = 0; *(uint64_t*)0x400000000678 = 0; *(uint64_t*)0x400000000680 = 0; *(uint32_t*)0x400000000688 = 0x10; *(uint32_t*)0x40000000068c = 0; *(uint32_t*)0x400000000690 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x400000000600ul, /*size=*/0x94ul); if (res != -1) r[1] = res; *(uint64_t*)0x400000000000 = 0x400000000040; memcpy((void*)0x400000000040, "contention_end\000", 15); *(uint32_t*)0x400000000008 = r[1]; *(uint32_t*)0x40000000000c = 0; *(uint64_t*)0x400000000010 = 0; syscall(__NR_bpf, /*cmd=*/0x11ul, /*arg=*/0x400000000000ul, /*size=*/0x10ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x3ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x400000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x400001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); const char* reason; (void)reason; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }