// https://syzkaller.appspot.com/bug?id=94100cff4d9a032b284ae1f06f9a8baaddf0a419 // 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 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; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (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) { } } #define SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); } #define SYZ_HAVE_RESET_TEST 1 static void reset_test() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter; for (iter = 0;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); reset_test(); 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 < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } #ifndef __NR_accept4 #define __NR_accept4 364 #endif #ifndef __NR_clock_adjtime #define __NR_clock_adjtime 343 #endif #ifndef __NR_clock_gettime #define __NR_clock_gettime 265 #endif #ifndef __NR_clone #define __NR_clone 120 #endif #ifndef __NR_eventfd2 #define __NR_eventfd2 328 #endif #ifndef __NR_execve #define __NR_execve 11 #endif #ifndef __NR_fcntl #define __NR_fcntl 55 #endif #ifndef __NR_fsetxattr #define __NR_fsetxattr 228 #endif #ifndef __NR_fstat #define __NR_fstat 108 #endif #ifndef __NR_ftruncate #define __NR_ftruncate 93 #endif #ifndef __NR_getsockopt #define __NR_getsockopt 365 #endif #ifndef __NR_getuid #define __NR_getuid 24 #endif #ifndef __NR_ioctl #define __NR_ioctl 54 #endif #ifndef __NR_mkdirat #define __NR_mkdirat 296 #endif #ifndef __NR_mknod #define __NR_mknod 14 #endif #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_mprotect #define __NR_mprotect 125 #endif #ifndef __NR_open #define __NR_open 5 #endif #ifndef __NR_pipe2 #define __NR_pipe2 331 #endif #ifndef __NR_ppoll #define __NR_ppoll 309 #endif #ifndef __NR_rmdir #define __NR_rmdir 40 #endif #ifndef __NR_sched_setaffinity #define __NR_sched_setaffinity 241 #endif #ifndef __NR_sendfile #define __NR_sendfile 187 #endif #ifndef __NR_sendmsg #define __NR_sendmsg 370 #endif #ifndef __NR_setsockopt #define __NR_setsockopt 366 #endif #ifndef __NR_socket #define __NR_socket 359 #endif #ifndef __NR_timer_create #define __NR_timer_create 259 #endif #ifndef __NR_timerfd_gettime #define __NR_timerfd_gettime 326 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { long res = 0; res = syscall(__NR_socket, 0x10, 3, 0x10); if (res != -1) r[0] = res; syscall(__NR_ftruncate, -1, 0x1000000); syscall(__NR_getuid); syscall(__NR_fsetxattr, (long)r[0], 0, 0, 0, 2); syscall(__NR_fcntl, -1, 8, -1); res = syscall(__NR_socket, 0xa, 1, 0); if (res != -1) r[1] = res; memcpy((void*)0x20000000, "\x5d\x7e\xf8\xbd\x03\x8c\x2a\x22\x18\x22\x18\xff\xf0\xef\x68\x14\x57" "\x1c\x2e\x61\xa9\xd7\xe9\x9f\xb0\xa9\x90\x87\x98\xc0\x5f\xa0\xf7\x50" "\x62\xfb\x0e\xa5\xea\xf0\xaa\x7e\x88\xc8\x29\xd4\x3b\x67\xab\xb1\x45" "\x6b\xe2\xbd\x45\x0f\x89\x3f\x71\x80\xff\xea\xee\x73\xd4\x08\x16\xa6" "\xfe\xbc\x07\x63\xf4\x65\x88\x93\x77\x9e\xbc\x14\x05\xbf\x18\x11\x4b" "\xb0\x98", 87); syscall(__NR_setsockopt, (long)r[1], 0x29, 0x40, 0x20000000, 0x57); syscall(__NR_rmdir, 0); syscall(__NR_mmap, 0x20000000, 0xe7e000, 4, 0x31, -1, 0); *(uint32_t*)0x20000fc0 = 0; *(uint32_t*)0x20000fc4 = 0x2000000; *(uint32_t*)0x20000fc8 = 0; *(uint32_t*)0x20000fcc = 0; *(uint32_t*)0x20000fd0 = 0; *(uint32_t*)0x20000fd4 = 0; *(uint32_t*)0x20000fd8 = 0; *(uint32_t*)0x20000fdc = 0; *(uint32_t*)0x20000fe0 = 0; *(uint32_t*)0x20000fe4 = 0; *(uint32_t*)0x20000fe8 = 0; *(uint32_t*)0x20000fec = 0; *(uint32_t*)0x20000ff0 = 0xfffffffd; *(uint32_t*)0x20000ff4 = 0; *(uint32_t*)0x20000ff8 = 0; *(uint32_t*)0x20000ffc = 0; *(uint32_t*)0x20001000 = 0; *(uint32_t*)0x20001004 = 0; *(uint32_t*)0x20001008 = 0; *(uint32_t*)0x2000100c = 0; *(uint32_t*)0x20001010 = 0; *(uint32_t*)0x20001014 = 0; *(uint32_t*)0x20001018 = 0; *(uint32_t*)0x2000101c = 0; *(uint32_t*)0x20001020 = 0; *(uint32_t*)0x20001024 = 0; syscall(__NR_clock_adjtime, 0, 0x20000fc0); syscall(__NR_open, 0, 0x200, 0x92); syscall(__NR_ioctl, -1, 0x40046208, 0); syscall(__NR_timerfd_gettime, -1, 0); syscall(__NR_fstat, -1, 0); syscall(__NR_socket, 0xf, 6, 0); syscall(__NR_accept4, 0xffffff9c, 0, 0, 0x800); syscall(__NR_socket, 0xa, 2, 0x88); syscall(__NR_pipe2, 0x20000140, 0); syscall(__NR_open, 0, 0x28080, 0x24); syscall(__NR_sendmsg, -1, 0, 0); syscall(__NR_mprotect, 0x20000000, 0x800000, 6); syscall(__NR_mkdirat, -1, 0, 0x1ff); syscall(__NR_sched_setaffinity, 0, 0, 0); syscall(__NR_clone, 0x2001ffb, 0, 0x99999999, 0, -1); syscall(__NR_mknod, 0, 0xff7, 0xfffffffd); res = syscall(__NR_eventfd2, 0, 0); if (res != -1) r[2] = res; syscall(__NR_getsockopt, -1, 6, 0x1d, 0, 0); syscall(__NR_timer_create, 0, 0, 0); syscall(__NR_ioctl, -1, 0x89a1, 0); syscall(__NR_ftruncate, -1, 0x280080); syscall(__NR_sendfile, -1, -1, 0, 0xfffffffe); syscall(__NR_clock_gettime, 0, 0); syscall(__NR_ftruncate, (long)r[2], 0x3f); *(uint32_t*)0x20000000 = -1; *(uint16_t*)0x20000004 = 1; *(uint16_t*)0x20000006 = 0; syscall(__NR_ppoll, 0x20000000, 1, 0, 0, 0); syscall(__NR_setsockopt, -1, 0, 0, 0, 0); syscall(__NR_socket, 0xa, 1, 0); syscall(__NR_clone, 0x2001ffb, 0, 0x99999999, 0, -1); syscall(__NR_mknod, 0, 0xff7, 0xfffffffd); syscall(__NR_execve, 0, 0, 0); } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }