// https://syzkaller.appspot.com/bug?id=0966a1f8b55b4c30ee9760b843eaaf8cf1d92669 // 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(long a0, 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; } #ifndef __NR_close #define __NR_close 6 #endif #ifndef __NR_execve #define __NR_execve 11 #endif #ifndef __NR_mknod #define __NR_mknod 14 #endif #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_pipe #define __NR_pipe 42 #endif #ifndef __NR_socket #define __NR_socket 359 #endif #ifndef __NR_splice #define __NR_splice 313 #endif #ifndef __NR_vmsplice #define __NR_vmsplice 316 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); long res = 0; res = syscall(__NR_pipe, 0x20000140); if (res != -1) { r[0] = *(uint32_t*)0x20000140; r[1] = *(uint32_t*)0x20000144; } res = syscall(__NR_socket, 2, 2, 0); if (res != -1) r[2] = res; syscall(__NR_close, (long)r[2]); memcpy((void*)0x200000c0, "attr/current", 13); syz_open_procfs(0, 0x200000c0); *(uint32_t*)0x200002c0 = 0x20000000; memcpy((void*)0x20000000, "\xc3", 1); *(uint32_t*)0x200002c4 = 1; syscall(__NR_vmsplice, (long)r[1], 0x200002c0, 1, 8); syscall(__NR_splice, (long)r[0], 0, (long)r[2], 0, 0x10005, 0); memcpy((void*)0x20000100, "./file0", 8); syscall(__NR_mknod, 0x20000100, 0x1040, 0); memcpy((void*)0x200000c0, "./file0", 8); syscall(__NR_execve, 0x200000c0, 0, 0); return 0; }