// https://syzkaller.appspot.com/bug?id=2482dbdc75808e95f27907b6a48676dab2f56417 // 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; } 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)) { } // openat$auto_kernfs_file_fops_kernfs_internal arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 73 79 73 2f 6d 6f 64 75 6c 65 2f 73 67 2f 70 61 72 61 6d // 65 74 65 72 73 2f 73 63 61 74 74 65 72 5f 65 6c 65 6d 5f 73 7a 00} // (length 0x2a) // } // flags: open_flags = 0x22001 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_kernfs_file_fops_kernfs_internal memcpy((void*)0x200000000000, "/sys/module/sg/parameters/scatter_elem_sz\000", 42); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000000ul, /*flags=O_NOFOLLOW|FASYNC|O_WRONLY*/ 0x22001, /*mode=*/0); if (res != -1) r[0] = res; // write$auto arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {30 00 a6 cc 0d 91 51 55 9d 49 da 1b ad b1 9e c8 54 74 a8 94 // 9c 8a e2 c7 63 4f 4d b6 a3 2c 21 6f 9e b0 ad 54 fb 52 a1 59 94 56 5b // 38 04 63 df 3a 5d d9 94 26 81 e2 13 8f ea 23 f8 46 bb 4f 4f 5d 65 5b // ab 78 6f d9 90 bb f9 cd c0 c9 00 da ac dd 1a dd dd b9 6f 1a ab d5 08 // c1 04 7a d0 49 3e 8f 00 e5 1c 2a ed 60 fd 15 88 0f 9a d5 a7 14 0c 7d // 3b ab 74 d1 61 6b e5 98 ea e3 7d 10 ab 0c 5f 19 9b 11 b2 35 56 55 4b // 93 cd 64 17 e4 cb 41 a5 5b 08 b8 3b 02 74 63 66 06 fb 44 91 ca 47 da // 61 3a 6b 5b 72 06 eb f0 c4 cb 10 ae a5 e9 75 9f de 4b a5 8e d6 8f d0 // 55 56 11 cb dd 81 be de 4c 2f 06 28 1d a5 59 07 c1 e9 28 85 52 96 e4 // 86 5c 13 a9 1a 26 19 8a 39 82 f0 83 0c f7 eb 00 00 00 00 00 00 00 00 // 76 92 3c 65 8b 3f 23 61 a3 20 aa 19 de 7d 10 a4 95 02 12 bb 13 eb 3c // c8 78 86 c6 12 77 32 75 e5 b0 8f da 88 52 f4 20 40 dc 8e aa f0 7b a8 // 2c a3 c7 01 5c 03 28 c0 b3 f3 f8 30 65 71 6f 1a e0 c6 d9 cf ab f4 5f // f2 ed 59 ff e0 be 82 63 58 5f 26 6f c4 53 87 9a 27 77 18 91 5d cf 17 // 39 3f 41 67 25 0b 12 86 f0 e2 64 dc aa 0f a8 76 c3 83 89 be 1c 5e 0d // fb db 14 8c 43 e9 3e fc f3 1a 2f 99 64 63 41 f4 42 f3 ba 17 ea} // (length 0x16b) // } // count: intptr = 0xe (8 bytes) // ] memcpy((void*)0x200000000200, "0\000\246\314\r\221QU\235I\332\033\255\261\236\310Tt\250\224\234\212" "\342\307cOM\266\243,!o\236\260\255T\373R\241Y\224V[8\004c\337:]" "\331\224&\201\342\023\217\352#\370F\273OO]e[" "\253xo\331\220\273\371\315\300\311\000\332\254\335\032\335\335\271o" "\032\253\325\b\301\004z\320I>\217\000\345\034*\355`" "\375\025\210\017\232\325\247\024\f};\253t\321ak\345\230\352\343}" "\020\253\f_\031\233\021\2625VUK\223\315d\027\344\313A\245[\b\270;" "\002tcf\006\373D\221\312G\332a:k[" "r\006\353\360\304\313\020\256\245\351u\237\336K\245\216\326\217\320UV" "\021\313\335\201\276\336L/" "\006(\035\245Y\a\301\351(\205R\226\344\206\\\023\251\032&" "\031\2129\202\360\203\f\367\353\000\000\000\000\000\000\000\000v\222<" "e\213?#a\243 " "\252\031\336}\020\244\225\002\022\273\023\353<" "\310x\206\306\022w2u\345\260\217\332\210R\364 " "@\334\216\252\360{\250,\243\307\001\\\003(" "\300\263\363\3700eqo\032\340\306\331\317\253\364_" "\362\355Y\377\340\276\202cX_&o\304S\207\232\'w\030\221]\317\0279?Ag%" "\v\022\206\360\342d\334\252\017\250v\303\203\211\276\034^" "\r\373\333\024\214C\351>\374\363\032/\231dcA\364B\363\272\027\352", 363); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x200000000200ul, /*count=*/0xeul); // openat$auto_sg_fops_sg arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 73 67 30 00} (length 0x9) // } // flags: open_flags = 0xc0482 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_sg_fops_sg memcpy((void*)0x200000000000, "/dev/sg0\000", 9); syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000000ul, /*flags=O_NOATIME|O_EXCL|O_CLOEXEC|O_APPEND|0x2*/ 0xc0482, /*mode=*/0); } 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; }