// https://syzkaller.appspot.com/bug?id=848446dc184d15d80ae51364da95fba01f04b127 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #ifndef __NR_renameat2 #define __NR_renameat2 316 #endif int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // mode: open_mode = 0x181 (8 bytes) // ] memcpy((void*)0x200000000000, "./file0\000", 8); syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000000ul, /*mode=S_IXOTH|S_IWUSR|S_IRUSR*/ 0x181ul); // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8) // } // mode: open_mode = 0x207 (8 bytes) // ] memcpy((void*)0x200000000040, "./file2\000", 8); syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000040ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|0x200*/ 0x207ul); // mount$overlay arguments: [ // src: const = 0x0 (8 bytes) // dst: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // type: ptr[in, buffer] { // buffer: {6f 76 65 72 6c 61 79 00} (length 0x8) // } // flags: mount_flags = 0x0 (8 bytes) // opts: ptr[in, fs_options[overlay_options]] { // fs_options[overlay_options] { // elems: array[fs_opt_elem[overlay_options]] { // fs_opt_elem[overlay_options] { // elem: union overlay_options { // lowerdir: fs_opt["lowerdir", stringnoz[filename]] { // name: buffer: {6c 6f 77 65 72 64 69 72} (length 0x8) // eq: const = 0x3d (1 bytes) // val: buffer: {2e} (length 0x1) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[overlay_options] { // elem: union overlay_options { // upperdir: fs_opt["upperdir", stringnoz[filename]] { // name: buffer: {75 70 70 65 72 64 69 72} (length 0x8) // eq: const = 0x3d (1 bytes) // val: buffer: {2e 2f 66 69 6c 65 32} (length 0x7) // } // } // comma: const = 0x2c (1 bytes) // } // } // common: array[fs_opt_elem[fs_options_common]] { // } // null: const = 0x2c (1 bytes) // } // } // ] memcpy((void*)0x200000000080, "./file0\000", 8); memcpy((void*)0x2000000000c0, "overlay\000", 8); memcpy((void*)0x200000000100, "lowerdir", 8); *(uint8_t*)0x200000000108 = 0x3d; memset((void*)0x200000000109, 46, 1); *(uint8_t*)0x20000000010a = 0x2c; memcpy((void*)0x20000000010b, "upperdir", 8); *(uint8_t*)0x200000000113 = 0x3d; memcpy((void*)0x200000000114, "./file2", 7); *(uint8_t*)0x20000000011b = 0x2c; *(uint8_t*)0x20000000011c = 0x2c; syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x200000000080ul, /*type=*/0x2000000000c0ul, /*flags=*/0ul, /*opts=*/0x200000000100ul); // chdir arguments: [ // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // ] memcpy((void*)0x200000000180, "./file0\000", 8); syscall(__NR_chdir, /*dir=*/0x200000000180ul); // renameat2 arguments: [ // oldfd: fd_dir (resource) // old: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8) // } // newfd: fd_dir (resource) // new: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 37 00} (length 0x8) // } // flags: renameat2_flags = 0x1 (8 bytes) // ] memcpy((void*)0x2000000001c0, "./file2\000", 8); memcpy((void*)0x200000000200, "./file7\000", 8); syscall(__NR_renameat2, /*oldfd=*/0xffffff9c, /*old=*/0x2000000001c0ul, /*newfd=*/0xffffff9c, /*new=*/0x200000000200ul, /*flags=RENAME_NOREPLACE*/ 1ul); return 0; }