// https://syzkaller.appspot.com/bug?id=779a64ccaefd969d5d9bc72a7c4fe39598d53884 // 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; res = syscall(__NR_socket, 0xaul, 2ul, 0x88); if (res != -1) r[0] = res; memcpy((void*)0x20000bc0, "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*)0x20000be0 = 0xe; *(uint32_t*)0x20000be4 = 4; *(uint32_t*)0x20000be8 = 0x520; *(uint32_t*)0x20000bec = 0xd0; *(uint32_t*)0x20000bf0 = 0; *(uint32_t*)0x20000bf4 = 0x118; *(uint32_t*)0x20000bf8 = 0; *(uint32_t*)0x20000bfc = 0xd0; *(uint32_t*)0x20000c00 = 0x2c0; *(uint32_t*)0x20000c04 = 0x450; *(uint32_t*)0x20000c08 = 0x450; *(uint32_t*)0x20000c0c = 0x450; *(uint32_t*)0x20000c10 = 0x2c0; *(uint32_t*)0x20000c14 = 4; *(uint64_t*)0x20000c18 = 0; memset((void*)0x20000c20, 0, 136); *(uint32_t*)0x20000ca8 = 0; *(uint16_t*)0x20000cac = 0xd0; *(uint16_t*)0x20000cae = 0x118; *(uint32_t*)0x20000cb0 = 0; *(uint64_t*)0x20000cb8 = 0; *(uint64_t*)0x20000cc0 = 0; *(uint16_t*)0x20000cc8 = 0x28; memcpy((void*)0x20000cca, "hl\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", 29); *(uint8_t*)0x20000ce7 = 0; *(uint8_t*)0x20000ce8 = 0; *(uint8_t*)0x20000ce9 = 0; *(uint16_t*)0x20000cf0 = 0x48; memcpy((void*)0x20000cf2, "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*)0x20000d0f = 1; *(uint64_t*)0x20000d10 = htobe64(0); *(uint64_t*)0x20000d18 = htobe64(1); memcpy((void*)0x20000d20, "veth1_to_hsr\000\000\000\000", 16); *(uint64_t*)0x20000d30 = 0; memset((void*)0x20000d38, 0, 136); *(uint32_t*)0x20000dc0 = 0; *(uint16_t*)0x20000dc4 = 0xd0; *(uint16_t*)0x20000dc6 = 0xf8; *(uint32_t*)0x20000dc8 = 0; *(uint64_t*)0x20000dd0 = 0; *(uint64_t*)0x20000dd8 = 0; *(uint16_t*)0x20000de0 = 0x28; memcpy((void*)0x20000de2, "hl\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", 29); *(uint8_t*)0x20000dff = 0; *(uint8_t*)0x20000e00 = 1; *(uint8_t*)0x20000e01 = 0; *(uint16_t*)0x20000e08 = 0x28; memcpy((void*)0x20000e0a, "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*)0x20000e27 = 0; *(uint32_t*)0x20000e28 = 0; *(uint8_t*)0x20000e30 = 0xfe; *(uint8_t*)0x20000e31 = 0x88; memset((void*)0x20000e32, 0, 12); *(uint8_t*)0x20000e3e = 0; *(uint8_t*)0x20000e3f = 1; *(uint8_t*)0x20000e40 = 0xfe; *(uint8_t*)0x20000e41 = 0x80; memset((void*)0x20000e42, 0, 13); *(uint8_t*)0x20000e4f = 0xbb; *(uint32_t*)0x20000e50 = htobe32(0); *(uint32_t*)0x20000e54 = htobe32(0); *(uint32_t*)0x20000e58 = htobe32(0); *(uint32_t*)0x20000e5c = htobe32(0); *(uint32_t*)0x20000e60 = htobe32(0); *(uint32_t*)0x20000e64 = htobe32(0); *(uint32_t*)0x20000e68 = htobe32(0); *(uint32_t*)0x20000e6c = htobe32(0); memcpy((void*)0x20000e70, "vcan0\000\000\000\000\000\000\000\000\000\000\000", 16); memcpy((void*)0x20000e80, "veth0_virt_wifi\000", 16); *(uint8_t*)0x20000e90 = 0; *(uint8_t*)0x20000ea0 = 0; *(uint16_t*)0x20000eb0 = 0; *(uint8_t*)0x20000eb2 = 0; *(uint8_t*)0x20000eb3 = 0; *(uint8_t*)0x20000eb4 = 0; *(uint32_t*)0x20000eb8 = 0; *(uint16_t*)0x20000ebc = 0x200; *(uint16_t*)0x20000ebe = 0x240; *(uint32_t*)0x20000ec0 = 0; *(uint64_t*)0x20000ec8 = 0; *(uint64_t*)0x20000ed0 = 0; *(uint16_t*)0x20000ed8 = 0x158; memcpy((void*)0x20000eda, "hashlimit\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000", 29); *(uint8_t*)0x20000ef7 = 3; memcpy( (void*)0x20000ef8, "bond_slave_" "1\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\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", 255); *(uint64_t*)0x20000ff8 = 0; *(uint64_t*)0x20001000 = 0xfffffffffffffffe; *(uint32_t*)0x20001008 = 0; *(uint32_t*)0x2000100c = 0; *(uint32_t*)0x20001010 = 0; *(uint32_t*)0x20001014 = 5; *(uint32_t*)0x20001018 = 0x88001; *(uint32_t*)0x2000101c = 0; *(uint8_t*)0x20001020 = 0; *(uint8_t*)0x20001021 = 0; *(uint64_t*)0x20001028 = 0; *(uint16_t*)0x20001030 = 0x40; memcpy((void*)0x20001032, "ERROR\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*)0x2000104f = 0; memcpy((void*)0x20001050, "\x20\x17\x97\x05\xe5\x40\x2a\x1b\x2e\x9a\xe5\x3b\xfc\xc8\x5d\xc3\x29" "\x50\x5d\x2f\xda\x1a\x43\xa5\x70\x43\x8f\x34\xd2\x7f", 30); memset((void*)0x20001070, 0, 136); *(uint32_t*)0x200010f8 = 0; *(uint16_t*)0x200010fc = 0xa8; *(uint16_t*)0x200010fe = 0xd0; *(uint32_t*)0x20001100 = 0; *(uint64_t*)0x20001108 = 0; *(uint64_t*)0x20001110 = 0; *(uint16_t*)0x20001118 = 0x28; memset((void*)0x2000111a, 0, 29); *(uint8_t*)0x20001137 = 0; *(uint32_t*)0x20001138 = 0xfffffffe; syscall(__NR_setsockopt, r[0], 0x29, 0x40, 0x20000bc0ul, 0x580ul); res = syscall(__NR_socket, 0xaul, 2ul, 0); if (res != -1) r[1] = res; *(uint8_t*)0x200000c0 = 0xfe; *(uint8_t*)0x200000c1 = 0x80; memset((void*)0x200000c2, 0, 13); *(uint8_t*)0x200000cf = 0xaa; *(uint32_t*)0x200000d0 = 0; *(uint32_t*)0x200000d4 = 0; syscall(__NR_ioctl, r[1], 0x89a1, 0x200000c0ul); *(uint8_t*)0x200005c0 = 0xfe; *(uint8_t*)0x200005c1 = 0x80; memset((void*)0x200005c2, 0, 13); *(uint8_t*)0x200005cf = 0xaa; *(uint8_t*)0x200005d0 = 0xfc; *(uint8_t*)0x200005d1 = 1; memset((void*)0x200005d2, 0, 13); *(uint8_t*)0x200005df = 0; *(uint8_t*)0x200005e0 = 0xfc; *(uint8_t*)0x200005e1 = 0; memset((void*)0x200005e2, 0, 13); *(uint8_t*)0x200005ef = 0; *(uint32_t*)0x200005f0 = 0; *(uint16_t*)0x200005f4 = 0; *(uint16_t*)0x200005f6 = 0; *(uint32_t*)0x200005f8 = 0; *(uint64_t*)0x20000600 = 0x8000000006; *(uint32_t*)0x20000608 = 0; *(uint32_t*)0x2000060c = 0; syscall(__NR_ioctl, r[1], 0x89a0, 0x200005c0ul); res = syscall(__NR_socket, 0x10ul, 3ul, 0xc); if (res != -1) r[2] = res; *(uint64_t*)0x200016c0 = 0; *(uint32_t*)0x200016c8 = 0; *(uint64_t*)0x200016d0 = 0x20001680; *(uint64_t*)0x20001680 = 0x20001600; *(uint32_t*)0x20001600 = 0x2c; *(uint8_t*)0x20001604 = 0; *(uint8_t*)0x20001605 = 0xb; *(uint16_t*)0x20001606 = 0x401; *(uint32_t*)0x20001608 = 0; *(uint32_t*)0x2000160c = 0; *(uint8_t*)0x20001610 = 0xa; *(uint8_t*)0x20001611 = 0; *(uint16_t*)0x20001612 = htobe16(0); *(uint16_t*)0x20001614 = 8; STORE_BY_BITMASK(uint16_t, , 0x20001616, 2, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20001617, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20001617, 0, 7, 1); *(uint32_t*)0x20001618 = htobe32(0); *(uint16_t*)0x2000161c = 5; *(uint16_t*)0x2000161e = 1; memset((void*)0x20001620, 0, 1); *(uint16_t*)0x20001624 = 8; STORE_BY_BITMASK(uint16_t, , 0x20001626, 3, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x20001627, 1, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x20001627, 0, 7, 1); *(uint32_t*)0x20001628 = htobe32(0); *(uint64_t*)0x20001688 = 0x2c; *(uint64_t*)0x200016d8 = 1; *(uint64_t*)0x200016e0 = 0; *(uint64_t*)0x200016e8 = 0; *(uint32_t*)0x200016f0 = 0; syscall(__NR_sendmsg, r[2], 0x200016c0ul, 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; }