// https://syzkaller.appspot.com/bug?id=42a641dd303d7d624a19371a24eb958f2643b718 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include static long syz_open_procfs(volatile long a0, volatile long a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == -1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } uint64_t r[1] = {0xffffffffffffffff}; 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; intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // syz_open_procfs$userns arguments: [ // pid: pid (resource) // file: ptr[in, buffer] { // buffer: {6e 73 2f 75 73 65 72 00} (length 0x8) // } // ] // returns fd_userns memcpy((void*)0x2000000001c0, "ns/user\000", 8); res = -1; res = syz_open_procfs(/*pid=*/0, /*file=*/0x2000000001c0); if (res != -1) r[0] = res; // open_by_handle_at arguments: [ // mountdirfd: fd (resource) // handle: ptr[in, file_handle] { // union file_handle { // ceph_nfs_confh: file_handle_t[FILEID_INO32_GEN_PARENT, // ceph_nfs_confh] { // handle_bytes: bytesize = 0x10 (4 bytes) // handle_type: const = 0xf1 (4 bytes) // f_handle: ceph_nfs_confh { // ino: int64 = 0x1002 (8 bytes) // parent_ino: int64 = 0x10000000 (8 bytes) // } // } // } // } // flags: open_flags = 0x400040 (8 bytes) // ] *(uint32_t*)0x200000000000 = 0x10; *(uint32_t*)0x200000000004 = 0xf1; *(uint64_t*)0x200000000008 = 0x1002; *(uint64_t*)0x200000000010 = 0x10000000; syscall(__NR_open_by_handle_at, /*mountdirfd=*/r[0], /*handle=*/0x200000000000ul, /*flags=__O_TMPFILE|O_CREAT*/ 0x400040ul); return 0; }